【发布时间】:2016-11-26 19:03:17
【问题描述】:
我有一列已使用 pandas 转换为日期时间,因此现在采用 datetime64 格式。
LOCAL_TIME_ON
2014-06-21 15:32:09
2014-06-07 20:17:13
我想将小时提取到一个新列。我发现唯一可行的方法如下,但是,我得到了一个 SettingWithCopyWarning。有没有人有更清洁的方法可以做到这一点?
TRIP_INFO_TIME['TIME_HOUR'] = pd.DatetimeIndex(TRIP_INFO_TIME['LOCAL_TIME_ON']).hour.astype(int)
C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\pydevconsole.py:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy '''
【问题讨论】:
标签: python-2.7 pandas