0

After using the groupby and sum operations as follows:

companyGrouped = dailyStocks.groupby(['SYMBOL'])
sumByCompany = companyGrouped.sum()

I end up with a new row for the group by and sum key, this is undesirable as I later want to merge this with another dataframe using [SYMBOL]. AN image of the table, obtained using: sumByCompany.head() is shown below.

I've tried a few things to get round this issue, but trying to manually delete this row and set the index as 'SYMBOL' does not seem elegant! Thanks for any help!!!

enter image description here

jfive
  • 1,291
  • 3
  • 14
  • 21

1 Answers1

0

Solved with df.reset_index(level=0, inplace=True)

enter link description here

Community
  • 1
  • 1
jfive
  • 1,291
  • 3
  • 14
  • 21