我想从这一栏中提取出“A”。在这之后,我希望能够从同一行中与“A”相关联的其他列打印其他数据。 但是,我的代码打印了这个:
outputs:
UniqueCarrier NaN
CancellationCode NaN
Name: CancellationCode, dtype: object
None
“CancellationCode”列如下所示
CancellationCode:
NaN
A
NaN
B
NaN
我想让它以带有过滤的行和列的数据框格式打印。 这是我的代码如下: 先谢谢
cancellation_reason = (flight_data_finalcopy["CancellationCode"] == "A")
cancellation_reasons_filtered = cancellation_reason[["UniqueCarrier", "AirlineID", "Origin"]]
print(display(cancellation_reasons_filtered))
答案 0 :(得分:1)
试试这个
cancellation_reason=flight_data_finalcopy[flight_data_finalcopy["CancellationCode"] == "A"]
cancellation_reasons_filtered = cancellation_reason[["UniqueCarrier", "AirlineID", "Origin"]]
print(display(cancellation_reasons_filtered))