手工时间帐单:
date,tI,tO,tC,tM,tF,tS Pt,Pd,Pl,Po
110701,0.00,11.5,0.00,2.50,4.00,7.50
110704,3.00,0.00,1.75,4.75,6.75,8.00
...
110726,1.50,4.25,0.00,1.00,9.75,7.50 8, 6, 1, 4
110727,4.50,2.50,0.00,4.00,5.00,7.50 8, 5, 2, 8
date 含义
,tI 输入
,tO 输出
,tC 交流
,tM 杂务
,tF 家庭
,tS 睡眠
Pt 蕃茄钟
,Pd DONE 蕃茄钟
,Pl LOST 任务钟
,Po OUT 蕃茄钟
不同版本的 aTL2 数据:
# android 版本
活动类别,持续时间,开始时间,结束时间,备注
Chaos,3.7,04/01 20:54,04/02 00:35,
...
活动类别,持续时间,Percent
Life,364.5,47.5
Output,182.5,23.8
Chaos,127.0,16.5
Livin,70.3,9.2
Input,23.5,3.1
其他,0.1,0.0
总计,768.0
# iOS 6.*
"活动类别","持续时间","开始时间","结束时间","备注"
"Chaos","05:30","2014-10-01 18:56","2014-10-02 00:26",
"用餐","01:15","2014-10-01 17:40","2014-10-01 18:56",
...
"活动类别","持续时间","%"
"睡眠","220:19","29.61"
"Chaos","144:28","19.42"
...
# iOS 7+
活动类别,持续时间,开始时间,结束时间,备注
GDG,1.20,2015-04-01 23:10,2015-04-02 00:22,
GDG,1.52,2015-04-01 21:39,2015-04-01 23:10,
...
活动类别,持续时间,Percent
Livin,230.98,30.1
Livin/睡眠,214.17,27.9
Livin/电影,12.05,1.6
Livin/娱乐,0.93,0.1
...
Output/Pt0+Life/交通,0.02,0.0
Life/用餐+Output/交流,0.02,0.0
其他,0.07,0.0
总计,768.00
所以,要进行一系列数据整理先,这就是 R 难以折腾的了...
In [1]:
print "是也乎"
In [2]:
%install_ext https://raw.github.com/cjdrake/ipython-magic/master/gvmagic.py
In [4]:
%load_ext gvmagic
In [21]:
%%dot digraph G4data2chat {
graph [label="时间帐单历史数据分析{流程图}"
,fontsize=14.0
,labeljust="l",labelloc="t",center=1
,ranksep=0.3,center=1,ratio=compress
,rankdir=BT
];
node[fontsize=11.0,height=0.3
,shape=component
];
edge [fontsize=9.0,fontcolor="#333333"
,arrowsize=0.6,arrowhead=vee,arrowtail=none
,style="setlinewidth(0.5)"
];
D4LOG [label=".log\n手工记录",shape=box3d];
D4ATL [label="aTimeLogger2\nApp.记录",shape=box3d];
LOAER [label="数据导入器"];
D2CSV [label=".csv数据表",shape=box3d];
IPYNB [label="IP[y]:notebook"];
PANDAS [label="Pandas"];
MATPLO [label="matplotlib"];
{D4LOG D4ATL}->LOAER;
LOAER->D2CSV [label="处理各种意外数据"];
D2CSV->IPYNB;
{PANDAS MATPLO}->IPYNB;
}
In [12]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
In [67]:
%pylab inline
In [1]:
ls csv/aTLer_14*
In [94]:
ls log/zq-tilog-10*
In [97]:
ls data/atl2_13*
In [186]:
df = pd.read_csv('data/atl2_130201-130301.csv')
#df[:-1]
#df.plot(kind='area')
In [188]:
df['活动类别']
'''
_labels = []
for k in list(df[:-1]['活动类别']):
print k
if "其他" == k:
_labels.append('Others')
elif "总计"==k:
_labels.append('Totle')
else:
_labels.append(k)
print _labels
'''
Out[188]:
In [189]:
df[:-1]['Percent']
Out[189]:
In [191]:
labels = _labels#list(df['活动类别'])
sizes = list(df[:-1]['持续时间'])
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
#explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
plt.pie(sizes, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=90)
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')
plt.show()
In [13]:
df = pd.read_csv('data/pom_1108.txt')
#df.index(df['date'])
df.columns
#df.describe()
#df.plot(kind='area', stacked=False)
Out[13]:
In [16]:
df.plot(kind='area', stacked=False)
Out[16]:
In [158]:
df = pd.read_csv('data/_all_atlogger2.csv')
df.head()
#df.columns
Out[158]:
In [159]:
df.plot(kind='area', stacked=False)
Out[159]:
In [160]:
df.plot(kind='kde', stacked=False)
Out[160]:
In [2]:
import pandas as pd
import matplotlib.pyplot as plt
In [5]:
ls data/pom_*
In [18]:
df = pd.read_csv('data/pom_1302.txt')
df.head()
Out[18]: