Hi, one of my tasks is failing with this error: ``...
# ask-the-community
s
Hi, one of my tasks is failing with this error:
Copy code
"['\\ufeffID'] not found in axis"
The original code is:
Copy code
df.drop([r"\ufeffID"], axis=1, inplace=True)
So it looks like another escape character is added during execution?
s
try
Copy code
df.drop("\ufeffID", axis=1, inplace=True)
r”" is used to denote rawstring, which will recognize “\u” as two separate character.
s
Sorry that’s what I tried the first time actually:
df.drop(["\ufeffID"], axis=1, inplace=True)
- it changes it errors out with an extra escape char:
"['\\ufeffID'] not found in axis"
s
can you try remove the list notation
["\ufeffID"]
just use
"\ufeffID"
instead
s
OK will try that thanks
s
another approach is selecting only valid column instead of dropping ( I suspect pandas may have problem with UTF-8 column).
Copy code
cols = df.columns.drop("\ufeffID")
df = df[cols]
159 Views