I have load a time series dataset in pandas(date/time and kwh) and I would like to build a histogram.I'm confused with the syntax.I used this(plt.hist(data.kwh)) but the result wasn't good.
2 Answers
Ideally when you build your histogram you should also use the "bins" parameter to make enough bins to hold your data.
import matplotlib.pyplot as plt
from math import ceil
# Load data as data.kwh
spacing = 10 # size on x axis of the bin to aim for
bins = ceil((data.kwh.max() - data.kwh.min()) / spacing)
plt.hist(data.kwh, bins=bins)
plt.show()