UserWarning: Pandas doesn't allow columns to be created via a new attribute name -

3137 views python
-1

I am trying to rename columns after I read in a csv file where I want to replace a portion of the column name. Here is my code where I want to remove 'yor_yogurt_march_poggen_output_with_shrink.' I get a user warning. I am using the pandas library if that matters.

df.dolumns = df.columns.str.replace('yor_yogurt_march_poggen_output_with_shrink.', '')

answered question

1 Answer

13

Double check df.dolumns is a typo in your post, but hopefully not in your code? Because it thinks you're trying to set a new attribute .dolumns for your df

posted this

Have an answer?

JD

Please login first before posting an answer.