本文介绍了如何在Pandas中找到数字列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说df
是一个熊猫DataFrame.我想找到所有数字类型的列.像这样:
Let's say df
is a pandas DataFrame.I would like to find all columns of numeric type.Something like:
isNumeric = is_numeric(df)
推荐答案
您可以使用DataFrame的select_dtypes
方法.它包括两个参数include和exclude.所以isNumeric看起来像:
You could use select_dtypes
method of DataFrame. It includes two parameters include and exclude. So isNumeric would look like:
numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']
newdf = df.select_dtypes(include=numerics)
这篇关于如何在Pandas中找到数字列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!