Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫时间序列:如何根据其他值仅绘制一天中的时间(无日期)?_Python_Pandas_Matplotlib_Time Series - Fatal编程技术网

Python 熊猫时间序列:如何根据其他值仅绘制一天中的时间(无日期)?

Python 熊猫时间序列:如何根据其他值仅绘制一天中的时间(无日期)?,python,pandas,matplotlib,time-series,Python,Pandas,Matplotlib,Time Series,由于我准备在一个相当大的数据集上做一些回归,我想首先将数据可视化 我们讨论的数据是2011年5月纽约地铁的数据(每小时进站次数、降雨、天气等) 创建数据帧时,我将小时和时间转换为datetime格式。 现在我意识到,从逻辑的角度来看,我想做的事情对于手头的例子来说没有多大意义。但是,我仍然希望根据每小时的条目绘制一天的确切时间。正如我所说,这不是很有意义,因为ENTRIESn_hourly是聚合的。但是为了论证,我们假设ENTRIESn_hourly与确切的时间戳明确相关 现在,我该怎么做,只记

由于我准备在一个相当大的数据集上做一些回归,我想首先将数据可视化

我们讨论的数据是2011年5月纽约地铁的数据(每小时进站次数、降雨、天气等)

创建数据帧时,我将小时和时间转换为datetime格式。
现在我意识到,从逻辑的角度来看,我想做的事情对于手头的例子来说没有多大意义。但是,我仍然希望根据每小时的条目绘制一天的确切时间。正如我所说,这不是很有意义,因为ENTRIESn_hourly是聚合的。但是为了论证,我们假设ENTRIESn_hourly与确切的时间戳明确相关

现在,我该怎么做,只记时间,不记日期,然后把它画出来

请在此处找到jupyter笔记本:


太多了

IIUC您可以这样做:

In [9]: weather_turnstile.plot.line(x=weather_turnstile.Date_Time.dt.time, y='ENTRIESn_hourly', marker='o', alpha=0.3)
Out[9]: <matplotlib.axes._subplots.AxesSubplot at 0xc2a63c8>

绝对完美!我不知道.dt字段@法比安·博斯勒,很高兴我能帮上忙。我已经添加了使用
dt
访问器时可以访问的属性列表…仅供参考:@TomAugspurger,谢谢!我已经添加了一个链接page@TomAugspurger非常感谢。我已经添加了一个到评论列表的链接!:->
In [10]: weather_turnstile.Date_Time.dt.
weather_turnstile.Date_Time.dt.ceil             weather_turnstile.Date_Time.dt.is_quarter_end   weather_turnstile.Date_Time.dt.strftime
weather_turnstile.Date_Time.dt.date             weather_turnstile.Date_Time.dt.is_quarter_start weather_turnstile.Date_Time.dt.time
weather_turnstile.Date_Time.dt.day              weather_turnstile.Date_Time.dt.is_year_end      weather_turnstile.Date_Time.dt.to_period
weather_turnstile.Date_Time.dt.dayofweek        weather_turnstile.Date_Time.dt.is_year_start    weather_turnstile.Date_Time.dt.to_pydatetime
weather_turnstile.Date_Time.dt.dayofyear        weather_turnstile.Date_Time.dt.microsecond      weather_turnstile.Date_Time.dt.tz
weather_turnstile.Date_Time.dt.days_in_month    weather_turnstile.Date_Time.dt.minute           weather_turnstile.Date_Time.dt.tz_convert
weather_turnstile.Date_Time.dt.daysinmonth      weather_turnstile.Date_Time.dt.month            weather_turnstile.Date_Time.dt.tz_localize
weather_turnstile.Date_Time.dt.floor            weather_turnstile.Date_Time.dt.nanosecond       weather_turnstile.Date_Time.dt.week
weather_turnstile.Date_Time.dt.freq             weather_turnstile.Date_Time.dt.normalize        weather_turnstile.Date_Time.dt.weekday
weather_turnstile.Date_Time.dt.hour             weather_turnstile.Date_Time.dt.quarter          weather_turnstile.Date_Time.dt.weekday_name
weather_turnstile.Date_Time.dt.is_month_end     weather_turnstile.Date_Time.dt.round            weather_turnstile.Date_Time.dt.weekofyear
weather_turnstile.Date_Time.dt.is_month_start   weather_turnstile.Date_Time.dt.second           weather_turnstile.Date_Time.dt.year