Hi I have a dataframe with 75 characters in the columns name that I don't need to make a chart with matplot so I was trying to use this line:
dfr = dfr.iloc[:,1:11].rename(columns=lambda x: x[75:], inplace=True)
But when I print it gives me none, I just need to remove this from the first 10 columns the rest are ok, but I'm not sure what is wrong, help please
You are trying to slice the dataframe and rename the sliced dataset columns and re-assigning to the original dataset which has a different shape.
Try renaming using dict
new_names = dfr.iloc[:,0:10].rename(columns=lambda x: x[75:]).columns #first 10 columns
dfr.rename(columns=dict(zip(dfr.columns,new_names)),inplace=True)