I'm trying to create histogram (x = duration column; y = count of occurrences) with matplotlib but without success. Here is my code:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_excel ("J:/edinburgh_bikes.xlsx")
x = df['duration'].to_numpy()
fig, ax = plt.subplots()
# the histogram of the data
n, bins, patches = plt.hist(x, 50, density=True, facecolor='g', alpha=0.75)
plt.xlabel('duration')
plt.ylabel('count')
plt.title('Histogram of bike ride duration')
plt.grid(True)
plt.show()
I dont think there is anything wrong with the code. The file has over 300 000 rows and when I tried run this code with sample of 1000 rows it worked just fine. Could it be that the problem is the size of the file? You can download the file from my github account. Thank you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…