简体   繁体   中英

Can anyone help me to fix this line of code?

I need to use a list comprehension to build a list of features from the columns of data that are not any of 'Name', 'Region', 'state', or 'AdultWeekend'. Can anyone help to fix this?

features = [data.columns for column in data.columns if column not in ['Name', 'Region', 'state', 'Adultweekend']]

Make that column before the for keyword, not data.columns . You want to collect the various values of column over the different loop iterations.

features = [column for column in data.columns if column not in ['Name', 'Region', 'state', 'Adultweekend']]

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