Python pandasデータフレームは、指定された列を除くすべての列を予期せず取得します



Python Pandas Dataframe Get All Columns Except Specified Column Unexpectedly



dfというデータフレームがあり、['a'、 'b'、 'c'、 'd'、 'e'、 'f'、 'g']列があるとしますが、すべてを除外するだけです。を除く列

col = df.columns.values.tolist() col.remove('e') # Do not use col = col.remove ('e'), or add remove to the above line of code directly, otherwise col is empty new_df = df[col] print(new_df)