You definitely need to clean up your data and restructure.
Instead of accessing to data-frame columns as attributes (e.g.
You've got the error because your df hasn't a column named
I think, your data have not been properly parsed (loaded). Consider passing a separator, e.g.
- remove semicolons and quotes from df; (you can use
.apply
method to do that)
- Do something like this before you start any analysis:
df = pd.concat([df, df['Detergent_Brands'].str.get_dummies()], axis=1).drop(['Detergent_Brands'], axis=1)
.
Instead of accessing to data-frame columns as attributes (e.g.
df.top
etc), consider using df['top']
, df['alpha']
. This is approach is more robust, especially in cases when column names collide with data-frame internal methods.You've got the error because your df hasn't a column named
alpha
(it hasn't a column named top
too). .get_dummies
should create these columns (but you need to clean up your data first).I think, your data have not been properly parsed (loaded). Consider passing a separator, e.g.
sep=';'
to the read_csv
function.