熊猫有一个很酷的功能,称为
select_dtypes,可以将排除或包含(或两者)作为参数。它根据dtype过滤数据帧。因此,在这种情况下,您将希望包含dtype的列
np.datetime64。要按整数过滤,您可以将
[np.int64,np.int32, np.int16, np.int],用于float
[np.float32, np.float64, np.float16,np.float]:,仅按数字列过滤:
[np.number]。
df.select_dtypes(include=[np.datetime64])
出:
date_col0 2017-02-011 2017-03-012 2017-04-013 2017-05-01
在:
df.select_dtypes(include=[np.number])
出:
col1 col20 1 21 1 22 1 23 1 2



