pandas.read_spss#

pandas.read_spss(path, usecols=None, convert_categoricals=True, dtype_backend=_NoDefault.no_default)[源代码]#

从文件路径加载 SPSS 文件,返回一个 DataFrame。

Parameters:
pathstr 或 Path

文件路径。

usecols类列表,可选

返回列的子集。如果为 None,则返回所有列。

convert_categoricalsbool,默认为 True

将分类列转换为 pd.Categorical。

dtype_backend{‘numpy_nullable’, ‘pyarrow’}, 默认 ‘numpy_nullable’

应用于结果 DataFrame 的后端数据类型(仍处于实验阶段)。行为如下:

  • "numpy_nullable":返回支持可空 dtype 的 DataFrame (默认)。

  • "pyarrow":返回 pyarrow 支持的可空 ArrowDtype DataFrame。

在 2.0 版本加入.

Returns:
DataFrame

Examples

>>> df = pd.read_spss("spss_data.sav")