我正在尝试在python中实现渐变下降实现,但是,我无法使用pandas显示数据。我希望数据显示为'release_date'作为x轴,'budget'作为y轴。 在我的下面的代码中,我将日期转换为系列的float64,以便将数值作为日期。
Python 3.5.2 (default, Aug 18 2017, 17:48:00)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import pandas
>>> import matplotlib.pyplot as plt
>>> movieData = pandas.read_csv('tmdb_5000_movies.csv', usecols = ['budget', 'release_date'])
>>> movieData['release_date'] = pandas.to_datetime(movieData['release_date'], format='%Y-%m-%d')
>>> movieData['release_date'] = movieData['release_date'].dt.year
>>> movieData = movieData.sort_values(['release_date'], ascending = True)
>>> movieData.plot('release_date', 'budget')
<matplotlib.axes._subplots.AxesSubplot object at 0x7f985fa3e470>
>>> plt.show()
>>>
>>> movieData.head()
budget release_date
4592 385907 1916.0
4661 245000 1925.0
2638 92620000 1927.0
4594 379000 1929.0
4457 0 1929.0
>>>
为什么这会返回一个空图?