📜  获取列索引 pandas - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:44.741000             🧑  作者: Mango

代码示例2
df = pd.read_csv('thanksgiving_w_age_income.csv')

# Obtain Column Indices:
gravy = df.columns.get_loc("Do you typically have gravy?")
meet_friends = df.columns.get_loc('Have you ever tried to meet up with hometown friends on Thanksgiving night?')
friendsgiving = df.columns.get_loc('Have you ever attended a "Friendsgiving?"')