python-pandas如何选取满足条件的特定的行和列

import pandas as pd

df1 = pd.read_csv("data/trans/bike_flow.csv")

# ['t_idx' 'r_idx' 'c_idx' 'bike_out_cnt' 'bike_in_cnt' 'flow_stay'  'flow_in' 'flow_out']
print(df1.columns.values)

# (23016, 8)
print(df1.shape)

# ['t_idx', 'bike_in_cnt']是取特定的列
# df1['bike_in_cnt'] > 10是取特定的行
df2 = df1[['t_idx', 'bike_in_cnt']][df1['bike_in_cnt'] > 10]

# (328, 2)
print(df2.shape)

你可能感兴趣的:(Python)