尽管该列的dtype是int64,但x轴仍然不正确。我什至尝试按升序对dataframe列进行排序。但这没用。
csv_path ="https://people.sc.fsu.edu/~jburkardt/data/csv/snakes_count_100.csv"
df3 = pd.read_csv(csv_path, usecols=[' "Game Length"'])
df3 = df3[1:51]
#df3.head()
ax = plt.axes()
plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right')
plt.hist(df3)
plt.legend()
plt.title('Game of snakes')
plt.ylabel('Frequency')
plt.xlabel('Game Length')
答案 0 :(得分:0)
您可以使用hist
类本身的DataFrame
方法。
通过对命令进行一些重新排序,您可以坚持执行其余代码:
csv_path ="https://people.sc.fsu.edu/~jburkardt/data/csv/snakes_count_100.csv"
df3 = pd.read_csv(csv_path, usecols=[' "Game Length"'])
df3 = df3[1:51]
df3.hist()
ax = plt.axes()
plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right')
plt.legend()
plt.title('Game of snakes')
plt.ylabel('Frequency')
plt.xlabel('Game Length')