Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling for pandas stacked column dataframe #7804

Closed
LeeTZ opened this issue Sep 20, 2018 · 0 comments
Closed

Better handling for pandas stacked column dataframe #7804

LeeTZ opened this issue Sep 20, 2018 · 0 comments
Assignees

Comments

@LeeTZ
Copy link
Contributor

LeeTZ commented Sep 20, 2018

For a simple file beakerxdata.csv:

time,downloads,package
20180906 20:00:00 -0400,21,beakerx
20180906 20:00:00 -0400,2,jlab
20180907 20:00:00 -0400,23,beakerx
20180907 20:00:00 -0400,1,jlab
20180908 20:00:00 -0400,3,beakerx
20180908 20:00:00 -0400,123,jlab
20180909 20:00:00 -0400,32,beakerx
20180909 20:00:00 -0400,31,jlab
20181006 20:00:00 -0400,21,beakerx
20181006 20:00:00 -0400,2,jlab
20181007 20:00:00 -0400,23,beakerx
20181007 20:00:00 -0400,1,jlab
20181008 20:00:00 -0400,3,beakerx
20181008 20:00:00 -0400,123,jlab
20181009 20:00:00 -0400,32,beakerx
20181009 20:00:00 -0400,31,jlab

If we do

mini_df = pd.read_csv('beakerxdata.csv')
mini_df['downloads'] = pd.to_numeric(mini_df['downloads'])
mini_df['time'] = pd.DatetimeIndex(mini_df['time']).to_period('M').to_timestamp(how='end')
s = mini_df.groupby([pd.Grouper(key='time',freq='M'), 'package']).sum().reset_index()
n = s[['time','package','downloads']].set_index(['time','package']).unstack('time')
n

This should be the expected behavior:
screenshot from 2018-09-24 18-39-16

However in our table the columns are shown in timestamps, not in readable format
screenshot from 2018-09-24 18-39-32

piorek added a commit that referenced this issue Sep 26, 2018
piorek added a commit that referenced this issue Sep 26, 2018
piorek added a commit that referenced this issue Sep 26, 2018
LeeTZ pushed a commit that referenced this issue Oct 1, 2018
)

* #7804: shown timestamps in readable format in header columns

* #7804 handle date object in column name

* #7804: shown timestamps in readable format in header columns, clear example

* #7804 change separator

* #7804 fix
@LeeTZ LeeTZ closed this as completed Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants