我有以下熊猫数据框,其中索引是日期。
>>>df
Date Mean NDVI STD R² Satellite
2018/05/07 0.139239 0.0324461 0.121766 Satellite B
2018/05/15 0.130177 0.0340713 0.0832709 Satellite B
2018/05/17 0.0852999 0.0667223 0.0344545 Satellite B
2018/05/30 0.0366202 0.0419196 0.0029048 Satellite B
2018/08/18 0.621853 0.0552849 0.560544 Satellite B
2018/09/04 0.51118 0.0636208 0.209225 Satellite B
2018/07/12 0.0284805 0.00935047 0.493559 Satellite C
2018/07/21 0.0438943 0.0158732 0.404927 Satellite C
2018/08/13 0.0418866 0.00945358 0.285964 Satellite C
2018/08/22 0.0427927 0.0124615 0.186457 Satellite C
2018/08/29 0.0396067 0.0131304 0.267189 Satellite C
2018/09/23 -0.0008 0.00986078 0.013689 Satellite C
>>>df2.index
Index(['2018/05/07', '2018/05/15', '2018/05/17', '2018/05/30', '2018/06/01',
'2018/06/04', '2018/07/12', '2018/07/21', '2018/08/13',
'2018/08/22', '2018/08/29', '2018/09/23'],
dtype='object')
我需要绘制从卫星B收集的所有图像的平均NDVI(相对于日期)。为此,我需要创建一个新的数据框,其中仅包含卫星B的数据。有什么方法可以将它们设置为以下数据帧吗?
>>>df2
Date Mean NDVI STD R² Satellite
2018/05/07 0.139239 0.0324461 0.121766 Satellite B
2018/05/15 0.130177 0.0340713 0.0832709 Satellite B
2018/05/17 0.0852999 0.0667223 0.0344545 Satellite B
2018/05/30 0.0366202 0.0419196 0.0029048 Satellite B
2018/08/18 0.621853 0.0552849 0.560544 Satellite B
2018/09/04 0.51118 0.0636208 0.209225 Satellite B
答案 0 :(得分:0)
只需:
df2 = df.loc[df['Satellite'] == 'Satellite B'].copy()