映射pandas系列时
s
到数据帧
x
,我收到SettingsWithCopy警告:
s.head()
84 2013-06-05 10:20:29
87 2013-06-05 15:27:56
469 2013-06-28 03:20:05
4670 2013-11-15 11:10:48
4673 2013-11-15 14:08:01
Name: timestamp, dtype: datetime64[ns]
y.head()
min max
0 2013-06-02 09:10:51 2013-06-02 10:27:44
1 2013-06-12 03:08:35 2013-06-12 03:08:35
2 2013-08-03 09:11:35 2021-01-26 23:05:17
x.head()
timestamp
4 2013-06-01 04:12:34
5 2013-06-01 04:19:08
6 2013-06-01 05:18:35
7 2013-06-01 06:00:19
8 2013-06-01 09:16:13
dfo = x.assign(a=1).merge(y.assign(a=1), on='a')
s = df.loc[(dfo['min']<=dfo['timestamp']) & (dfo['max']>=dfo['timestamp']), 'timestamp']
x['count']=x['timestamp'].map(s.value_counts()).fillna(0).astype(int)
<ipython-input-205-91489a4af264>: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
由于我正在基于序列图创建一个新列,为什么会抛出错误(复制的切片是什么?),以及用什么正确的方法重写它
i.loc
因为我没有使用索引器?