我有一个如下所示的数据框,我希望能够提取“ Holiday”列中表示“ N”的所有值并创建一个新列“ NonHoliday”
My_data
Date Holiday
1 Y
2 N
3 N
4 Y
5 Y
我的代码
My_data['Holiday'] = My_data['Holiday'] == 'N'
给出错误消息,我想要这样的东西
Date NonHoliday
2 N
3 N
答案 0 :(得分:1)
您可以使用:
params.RequestItems['Items'] = [];
for (let i = 0; i < allRecordsWithSameProjectId.length; i++) {
params.RequestItems['Items'].push({ DeleteRequest: {
Key: {
projectId: allRecordsWithSameProjectId[i].projectId,
addedTime: allRecordsWithSameProjectId[i].addedTime
}
}
});
}
}
let operationResult = await docClient.batchWrite(params).promise();
或:
new_df = My_data.loc[My_data['Holiday'] == 'N']
然后:
new_df = My_data[My_data['Holiday'] == 'N']