简体   繁体   中英

Selecting columns for copying Pandas DataFrame

I would like to copy my existing df to another pandas dataframe. Basically if I need to specify columns and copy-then it's easy and can be done in such a manner:

df_copy = df[['col_A', 'col_B', 'col_C']].copy()

But is it possible to copy only the other columns which not specified using this approach? I tried that way but it seems to be wrong:

df_copy = df[~df['col_A', 'col_B', 'col_C']].copy()

Thanks in advance!

df.columns.isin()前面的否定如何~

df_copy_not = df[df.columns[~df.columns.isin(['col_A', 'col_B', 'col_C'])]]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM