Skip to content

Instantly share code, notes, and snippets.

@robinfang
Last active October 7, 2015 06:18
Show Gist options
  • Select an option

  • Save robinfang/24c7cb18c41c91f52b8c to your computer and use it in GitHub Desktop.

Select an option

Save robinfang/24c7cb18c41c91f52b8c to your computer and use it in GitHub Desktop.
转换时间序列
import pandas as pd
import sys
if __name__ == "__main__":
print sys.argv[0]
print sys.argv[1]
# print sys.argv[2]
if not len(sys.argv)==2:
print "usage: python t2s.py"
sys.exit()
f = open(sys.argv[1])
tl = f.readlines()
tl = map(str.strip,tl)
ts = pd.Series(tl)
ts = pd.to_datetime(ts)
df = pd.DataFrame(data=1,index=ts,columns=['A'])
result = df.resample("D",how="sum")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment