This scirpt is on how to sum up the time series.¶
I am watching a series of videos on machine learning. What I want is to find out the toltal time I have to spend on all the lectures.
So I decided to script it up. I just copy pasted the series name and timings into a text bcoz i'm lazy to code it up using request :)
Rest of the coding is in python pandas . Its very simple
In [1]:
import pandas as pd
In [2]:
with open( "ts.txt", 'r' ) as fh:
data = fh.readlines()
In [3]:
data[0:10]
Out[3]:
In [4]:
# capture all the time slot of each video into a list
ts = list()
for e,i in enumerate(data[0:]):
if i.startswith("Chapter"):
pass
if i.startswith(" "):
ts.append( "0:" + i.split(" ")[-1].replace("(",'').replace(")","").replace('\n','') )
print ts
Now to sum it up using pure python is time consuming. So I used pandas timedelta to convert it to a time series
In [5]:
tsSer = pd.Series(ts)
tsTd = pd.to_timedelta(tsSer)
print "Total Time taken for the entire Series to watch : ", tsTd.sum()
No comments:
Post a Comment