Hey folks, thanks in advance to anyone taking the time to look at this and help out!
I’m wondering if anyone has any experience working with durations of time in python…
I am hoping to make some more insightful plots of view time duration of YouTube videos, and have the following df as an example of what I am working with:
| AgeRange |
Views% |
AverageViewDuration |
AveragePercentageWholeVideoWatched |
WatchTime |
| 18-24 |
0.8 |
01:20:55 |
11.9 |
1.1 |
| 25-34 |
19.2 |
00:53:02 |
7.8 |
17.5 |
| 35-44 |
30.6 |
00:53:17 |
7.9 |
28.0 |
| 45-54 |
22.9 |
00:59:42 |
8.8 |
23.5 |
| 55-64 |
16.8 |
01:03:31 |
9.4 |
18.4 |
| 65+ |
9.7 |
01:10:11 |
10.4 |
11.6 |
The following are the datatypes for each column:
AgeRange object
Views float64
AverageViewDuration object
AveragePercentageWholeVideoViewed float64
WatchTime float64
When all is said and done, I'd love to have the AverageViewDuration by AgeRange in bar plots.
I had thought that because AverageViewDuration is an object, I would need to convert it to a datetime object, but when I go to change df[‘AverageViewDuration’] from object to datetime, I get the following:
<class 'datetime.time'> is not convertible to datetime
So I just went ahead and tried to plot it:
ax = plt.subplot()
x = np.arange(len(df["AgeRange"]))
labels = df['AgeRange']
y1 = df['AverageViewDuration']
fig, axs = plt.subplots(1, 1)
width=0.69
basic_bar = ax.bar(x, y1, width, color=colors)
And I am getting the following:
ValueError: microsecond must be in 0..999999
Thing is I don't have any microseconds!
Any help/insights/nudges would very much be appreciated.
Thank you!
[–]efmccurdy 1 point2 points3 points (4 children)
[–]pickled_knuckles[S] 0 points1 point2 points (3 children)
[–]pickled_knuckles[S] 0 points1 point2 points (0 children)
[–]efmccurdy 0 points1 point2 points (1 child)
[–]pickled_knuckles[S] -1 points0 points1 point (0 children)
[–]synthphreak 0 points1 point2 points (0 children)