I have a pandas dataframe like this:
'' count
sugar 420
milk 108
vanilla 450
...
The first column has no header and I would like to give it the name: 'ingredient'.
I created the dataframe from a csv file:
df = pd.read_csv('./data/file_name.csv', index_col=False, encoding="ISO-8859-1")
df = df['ingredient_group'] #selecting column
df = df.value_counts() #calculating string occurance which retu series obj
df = pd.DataFrame(df) #creating dataframe from series obj
How do I assign the name 'ingredient' to the first column which has currently no name?
I already tried:
df_count.rename(columns={'': 'ingredient'}, inplace=True)
df = pd.DataFrame(df, columns = ['ingredient','count']
