AttributeError: 'DataFrame' object has no attribute 'str' while trying to fix my dataframe
str.rstrip
is for Series
not DataFrame
.
df[perclist] = df[perclist].replace('%$', '', regex=True).astype('float') / 100.0
Tip: avoid to create a useless subset of your dataframe:
Replace:
percentages = (df.filter(like='%').columns)
perclist = percentages.tolist()
By:
perclist = df.columns[df.columns.str.contains('%')]