Last active
April 7, 2018 08:45
-
-
Save anatol-grabowski/c075f74b11a9a42b2c983d323bb83efa to your computer and use it in GitHub Desktop.
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
np.random.seed(123) | |
num_vals = 27 | |
index = pd.DatetimeIndex(start='jan 2 2018', periods=num_vals, freq='1D', name='date') | |
data = np.random.randn(num_vals) | |
dff = pd.DataFrame(data, index=index, columns=['val']) | |
dff.loc[:, 'weekday'] = dff.index.weekday | |
dff.loc[:, 'weekstart'] = dff.index - dff.index.weekday.astype('timedelta64[D]') | |
piv = dff.pivot(columns='weekday', values='val', index='weekstart') | |
piv.rename(inplace=True, columns={0: 'Mon', 1: 'Tue', 2: 'Wed', 3: 'Thu', 4: 'Fri', 5: 'Sat', 6: 'Sun'}) | |
piv.dropna(inplace=True) | |
plt.boxplot(piv.T); | |
piv.T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment