I would like to group rows by time and I tried the following approach
import pandas as pd
df = pd.DataFrame({'time': ["2001-01-01 10:20:30,000",
"2001-01-01 10:20:31,000",
"2001-01-02 5:00:00,000"],
'val': [1, 2, 3]})
t = pd.DatetimeIndex(df.time)
df = df.groupby([t.day, t.hour, t.minute]).count()
The resulting dataframe is
time val
time time time
1 10 20 2 2
2 5 0 1 1
The output I expect (or something similar):
time count
1 1-10-20 2
2 2-5-0 1
The plot I want: X-axis for minutes, Y-axis for count, ticks by day + hour (coarser than just minutes).
Questions:
1) Why the index consist of 3 time columns and how can I have the index with just a single column with elements like 1-10-20 and 2-5-0?
2) What is the best practice to have only one column with the results of count() instead of two columns time and val?
2) How can I plot this data (grouped by days/hours/minutes) with ticks in days and hours?
