0

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.

1
  • 1
    Welcome to Stack Overflow! Your question is quite unclear, please add some more information. A few lines of source code are often better than 1000 words :) Commented Mar 26, 2015 at 15:34

2 Answers 2

1

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()
Sign up to request clarification or add additional context in comments.

Comments

1
matplotlib.pyplot.hist(samples, bins = 101)

where samples is an array and bins is the number of bins you want in your histogram.

Alternatively, you can use pylab to performm this task:

pylab.hist(samples, bins = 101)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.