pandas 查看 DataFrame 列或具体值数据类型

数据示例:

# -*- coding:utf-8 -*-
import pandas as pd
df = pd.read_csv(r'e:\zsxq\v6\1\topics.csv', header=None)
df.head(10)
数据示例.png

需求:

现在需要筛选出指定时间范围内的所有行,那就需要知道索引为 1 的列的值是什么数据类型。

具体方法:

type(df)
pandas.core.frame.DataFrame
type(df[1])
pandas.core.series.Series
df.info()
info.png
df.dtypes
dtypes.png
type(df[1][0])
13.png
from pandas.api.types import is_string_dtype
from pandas.api.types import is_numeric_dtype
from pandas.api.types import is_timedelta64_dtype
is_string_dtype(df[1])
is_string_dtype.png

你可能感兴趣的:(pandas 查看 DataFrame 列或具体值数据类型)