熊猫/Numpydatetime64和datetime64[ns]有什么区别?另外,如何选择dtypedatetime64[ns]的Pandas DataFrame列?在
我尝试了以下方法:
for col in df.columns:
if (df[col].dtype == np.datetime64[ns]): #If column has dtype datetime64[ns]
print(col)
function(df[col]) ##apply a function to this column
## RESULT: NameError: name 'ns' is not defined
## If I try == np.datetime64, nothing gets printed.
我也试过:
^{pr2}$如何仅选择具有dtypedatetime64[ns]的列?
使用“选择类型”。 考虑一下这个df
在数据框类型在
^{pr2}$您可以使用select_dtypes选择datetime
你得到了
相关问题 更多 >
编程相关推荐