Suppose I have a dataframe indexed by datetime
:
> df.head()
value
2013-01-01 00:00:00 -0.014844
2013-01-01 01:00:00 0.243548
2013-01-01 02:00:00 0.463755
2013-01-01 03:00:00 0.695867
2013-01-01 04:00:00 0.845290
(...)
if I wanted to plot all values by date, I could do:
times = map(lambda x : x.date(), df.index)
values = df.value
plot(values, times)
Is there a more "pandas idiomatic" way to do it? I tried the .rename
method, but I got a assertion error:
df.rename(lambda x : x.time())
What I really wanted was to do something like a boxplot:
df.boxplot(by = lambda x : x.time())
but without the standard deviation boxes (which will be substituted by estimated confidence bands). Is there a way to do this with a simple pandas command?
I don't know if I was clear about what was the problem. The problem is that I have a datetime field as index of the dataframe, and I need to extract only the time part and plot the values by time. This will give me lots of points with the same x-axis, which is fine, but the rename
method seems to expect that each value in the resulting index is unique.