Created
February 21, 2018 09:38
-
-
Save yassineAlouini/87b9178c4a09e97acf2e94ee0c8606b0 to your computer and use it in GitHub Desktop.
Histogram computation on a multi-index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.DataFrame({'t': [1, 2, 3, 4, 5, 6], 'sid': [1, 1, 1, 2, 2, 2], 'time': [1, 2, 2, 2, 1, 1]}) | |
hist_df = df.groupby(['sid', 'time']).t.value_counts(bins=[1, 2, 3, 10]).reset_index(name='counts') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment