I have the following dataframe given:
point timestamp_local 0
0 A 2019-07-20 00:00:00 1
1 A 2019-07-20 01:00:00 3
2 B 2019-07-20 02:00:00 158
3 A 2019-07-20 02:30:00 324
4 B 2019-07-20 03:00:00 502
The dataframe tells me on which point
at which time timestamp_local
how many connections I had. The 0
is the count of the connections I had.
I want to plot this data now using the plotnine
library. I have done this already and its working when I use timestamps without times, e.g. 2019-07-20
. But when I use timestamps with times, e.g. 2019-07-20 00:00:00
its not working.
This is my python command to plot the data without times:
pn.ggplot(df, pn.aes(x="timestamp_local", y="0", group="point", color="point")) + pn.geom_line(stat="identity")
This returns a figure where I can see the counts per day grouped by the point.
I have now two questions:
- How can I plot the same result when using timestamps with times like
2019-07-20 01:00:00
(the data go over several days. So I cannot just cut of the date!) - How can I plot the same result grouped by month and year? (E.g.
2019-07
,2019-08
,2019-09
and so on...)
I would highly prefer a solution with the plotnine
library because there are more functinos I want to use later on e.g. smooth and so on. If its not possible with the plotnine
library I would like to have a figure where I have one line for each point in a different color and the same figure! Like in the figure above, red is point A, blue is point B.
Kind regards