Closed
Description
It always annoyed me that it was not possible to generate a histogram or kernel density estimation plot from a datetime column.
Is there interest in a solution following this approach?
Link to SO
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.DataFrame({"datetime": pd.to_datetime(np.random.randint(1582800000000000000, 1583500000000000000, 100, dtype=np.int64))})
fig, ax = plt.subplots()
df["datetime"].astype(np.int64).plot.hist(ax=ax)
labels = ax.get_xticks().tolist()
labels = pd.to_datetime(labels)
ax.set_xticklabels(labels, rotation=90)
plt.show()
I didn't look into the the pandas source code yet, but if there is interest in something like this I will look into it.
I think the main issue will be finding good x tick labels, if thats a requirement.
Greetings!