I am having issue to get a pandas dataframe with several observations into the correct format to display an eventplot. The 'creator' column should be the label used to distinguish the datasets.
import pandas as pd
from matplotlib import pyplot as plt
data = {
"creator": [1, 2, 1, 1, 2],
"creationdate": ["2019-03-13 16:43:55", "2019-03-13 16:43:55", "2019-03-15 15:52:05",
"2019-03-16 15:52:05", "2019-03-17 15:52:05"]
}
df = pd.DataFrame(data)
df["creationdate"] = pd.to_datetime(df["creationdate"])
# df
# creator creationdate
#0 1 2019-03-13 16:43:55
#1 2 2019-03-13 16:43:55
#2 1 2019-03-15 15:52:05
#3 1 2019-03-16 15:52:05
#4 2 2019-03-17 15:52:05
# Group by creator
grouped = df.groupby("creator")
# How can the data now be reshaped to actually display the plot
# ...
# TypeError: Invalid comparison between dtype=datetime64[ns] and int
fig = plt.eventplot(grouped)
plt.show()
I tried to iterate over the grouped array to extract the individual groups but this seems way to complex and unnecessary.
data = np.array([grouped.get_group(1)["creationdate"].to_numpy(), grouped.get_group(2)["creationdate"].to_numpy()])
