简体   繁体   English

谁能帮我修复这行代码?

[英]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'.我需要使用列表推导式从不是“名称”、“地区”、“州”或“AdultWeekend”的data列中构建功能列表。 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 .for关键字之前创建该column ,而不是data.columns You want to collect the various values of column over the different loop iterations.您想要在不同的循环迭代中收集column的各种值。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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