Last active
August 29, 2015 14:11
-
-
Save dberkholz/7d66deb2f50b47d72785 to your computer and use it in GitHub Desktop.
Weekly clustering of timestamps with pandas
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
#!/usr/bin/env python | |
import pandas as pd, numpy as np | |
d = pd.read_table('input.txt', skiprows=0, header=None, parse_dates=True, index_col=0) | |
d['values'] = np.ones(len(d)) | |
e = d.resample('w', how='sum') | |
f = e.fillna(value=0) | |
f.to_csv('output_weekly.txt', sep='\t') | |
#import matplotlib as mpl | |
#f.plot() | |
#mpl.pyplot.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment