Jul-14-2019, 03:49 AM
(Jul-14-2019, 01:11 AM)scidam Wrote: You definitely need to clean up your data and restructure.
- 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 usingdf['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 namedalpha
(it hasn't a column namedtop
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 theread_csv
function.
Dear Scidam, thank you very much for respond. I will try your instruction, if possible can you give some clarification on Apply Method that you recommended in your above comment. Once again, thank you.