I am trying to visualize the total number of calls made during the time interval, where x
is a month and y
is a sum of all calls made during that period.
I have a main DataFrame df1
with various columns, where I take two columns with 'date'
and 'duration'
values and resample it to a monthly period:
df2 = df1[['date', 'duration']]
monthly_df2 = df2.set_index('date').resample('M').sum()
I can get a nice DataFrame with the data I want:
2018-10-31 03:03:34
2018-11-30 03:22:21
2018-12-31 04:31:56
2019-01-31 04:02:31
The problem starts when I want to plot this data:
If I use plot() method directly to resampled DataFrame I can get a line graph, where y value is shown in nanoseconds, so value 03:03:34 transformed to 11014000000000 and so on.
When I use .plot.bar() method I have:
TypeError: Passing integers to fillna for timedelta64[ns] dtype is no longer supported. To obtain the old behavior, pass
pd.Timedelta(seconds=n)
instead.
I was looking through the stack overflow and other resources, but all the solutions for bar plots were posted before the pandas v1.0 was released and I also have same TypeError
if I use those solutions.
They changed it to Timedelta concept, but I cannot understand how I can use it in my situation: Timedelta
Could anyone suggest me a good way to overcome this issue