2016-08-14 8 views
1

かなり大きなデータセットでいくつかの回帰を行う準備をしているので、最初にデータを視覚化したいと思います。パンダの時系列:他の値に対して日(日付なし)のみをプロットする方法は?

私たちが話しているデータは、月のニューヨークの地下鉄(時給エントリー、雨、天候など)に関するデータで、2011年

私は日時フォーマットをパンダために時間と時間を変換するデータフレームを作成します。
今私がやりたいことは、手元の例の論理的な観点からはあまり意味がないことを理解しています。しかし、私はまだ毎時のエントリに対して正確な時刻をプロットしたいと思います。 ENTRIESn_hourlyが集約されて以来、私が言ったように、それはあまり意味がありません。しかし、ENTRIESn_hourlyが正確なタイムスタンプに明示的に関連していると仮定して、引数のためにしましょう。

今私は時代のみを取って日付を無視してそれをプロットする方法はありますか?

ここjupyterノートを見つけてください:https://github.com/FBosler/Udacity/blob/master/Example.ipynb

のTHXたくさん!あなたは、このようにそれを行うことができます

答えて

4

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> 

enter image description here

.dt accessorあなたは次の属性にアクセスすることができます:

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 
+0

完璧! .dtフィールドについて知らなかった! –

+0

@FabianBosler、うれしいことに助けてくれました。 'dt'アクセサを使用してアクセス可能な属性のリストを追加しました。 – MaxU

+2

FYI:http://pandas.pydata.org/pandas-docs/version/0.18.1/api.html#datetimelike -properties – TomAugspurger

関連する問題