I want to replace the words contains "conference" and "group" with "N/A" in the dataframe.
E.g.
"AAAI Conference"->"N/A" "Alibaba Group" -> "N/A"
The dataframe is called name, I try two ways to do this:
columns=['nameCurrentEmployer',
'name2ndEmployer', 'name3rdEmployer',
'name4thEmployer', 'name5thEmployer',
'name6thEmployer', 'name7thEmployer',
'name8thEmployer', 'name9thEmployer',
'name10thEmployer']
name.loc[name.str.contains(['conference','group'], case=False), columns] = 'N/A'
Prompt error AttributeError: 'DataFrame' object has no attribute 'str'
NAMES = pd.Series(name.values.flatten())
NAMES.loc[NAMES.str.contains(['conference','group'], case=False), columns] = 'N/A'
Now the error is
TypeError: unhashable type: 'list'
Thank you very much.
lower_case_with_underscoresstyle. Always share the entire error message. Do you not have a minimal reproducible example?