Created
October 5, 2015 17:34
-
-
Save nakamasato/019e400c126c3799ccec to your computer and use it in GitHub Desktop.
PandasのDataFrameをgroupごとにプロットする。 ref: http://qiita.com/gymnstcs/items/0c651566944c64e5efcb
This file contains 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
%matplotlib inline | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import numpy as np | |
import matplotlib | |
matplotlib.style.use('ggplot')#これでggplotのような画像ができる。 |
This file contains 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
loc_entropy.head() |
This file contains 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
for key, grp in loc_entropy.head(500).reset_index().groupby('user_id'): | |
plt.plot(grp['entropy'],label=key) | |
plt.show() |
This file contains 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
for key, grp in time_entropy.head(1000).reset_index().groupby('user_id'): | |
if len(grp['entropy']) != 1: | |
plt.hist(np.array(grp['entropy'])) | |
plt.show() |
This file contains 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
time_entropy.head(2000).reset_index().hist('entropy', by='user_id') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment