我试图根据数字和分类数据类型过滤列,然后为每个回归问题创建单独的列表。
问题是我无法使用.isin(['object','O'])执行此操作
列列表:
制造商157非null对象
模型157非空对象
Sales_in_thousands 157非null float64
four_year_resale_value 121非null float64
Vehicle_type 157非null对象
Price_in_thousands 155非null float64
Engine_size 156非null float64
马力156非零浮点64
轴距156非null float64
宽度156非null float64
Latest_Launch 157非null对象
Power_perf_factor 155非null float64
我想使用.isin([])来实现它,因为可以在列表中传递多个选项,但它不起作用
df.dtypes.loc[df.dtypes.isin(['object','O'])]
df.dtypes.loc[(df.dtypes == ('object')) | (df.dtypes == ('O'))]
制造商对象
模型对象
Vehicle_type对象
Latest_Launch对象
有一个方便的助手功能,正是你想要做的,select_dtypes
df.select_dtypes(include=['O'])
df.select_dtypes(exclude=['O'])