-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calories.py
47 lines (41 loc) · 1.22 KB
/
Calories.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pandas as pd
import glob
import datetime
# #readAllFiles
all_files = glob.glob("*.csv")
df = pd.concat((pd.read_csv(f) for f in all_files))
# # df = pd.read_excel("em290301_bike.xlsx",sep=";")
# print(df.head())
# print(df.shape)
#
# #concatenate all columns into one
df['concat'] = pd.Series(df.fillna('').values.tolist()).str.join('')
df = df[["concat"]]
# print(df.head())
# print(df.shape)
#
# #split columns into separate column
df_1 = df['concat'].str.split(';', 13, expand=True)
# print(df_1.head())
df_1 = df_1[[0,11,12]]
# # df_1= df_1[df_1[11] != 0]
# # df_1= df_1[df_1[12] != 0]
#asdsDFSDFadsasfdsadf\
adsfsdfsdfsdf
# #sort by values
SDGSRAFGsfgsdfgasfg
df_1[0] = pd.to_datetime(df_1[0])#,format="%d-%m-%Y %H:%M:%S")
df_1 = df_1.sort_values(by=[0],ascending=True)
aspdkmswdwkpfnmapdfmpkdasmf
calories_list = []
#subset dataframe from start time to end time
df_betTime = df_1["2019-03-28 13:11:00":"2019-03-28 13:12:10"]
# for i,j in df_betTime.iterrows():
# print(j[11],j[12])
#calculate calories
for i,j in df_betTime.iterrows():
calories = ((j[11] * j[12] * 2 * 3.14) / 60) * 0.05 * 0.860421 * 4
calories_list.append(calories)
print(calories_list)
# # print(df_1.iloc[0][11])
asdasdasdasdasfdsdfsdf