Python pandas - headers on two lines -


using pandas library python reading csv, grouping results sum.

grouped = df[['organization name','views']].groupby('organization name').sum().sort(columns='views',ascending=false).head(10) #bar chart section print grouped.to_string() 

unfortunately following result table:

                                      views organization name test1                                 112 test2                                 114 test3                                 115 

it seems column headers going on 2 separate rows.

because grouped on 'organization name', being used name index, can set none using:

grouped.index.name = none 

will remove line, display issue, data not in funny shape

alternatively if don't want 'organization name' become index pass as_index=false groupby:

grouped = df[['organization name','views']].groupby('organization name', as_index=false).sum().sort(columns='views',ascending=false).head(10) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -