Skip to content

ENH: Add kwargs to pandas.read_spss so that pyreadstat keyword args can be used #56356

Closed
@tinrobot2000

Description

@tinrobot2000

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I have recently used pandas to convert .sav files to csv using pandas.read_spss, this has typically worked without issue.
I now have a .sav file that has text which is causing a read error in pandas.
I have been able to resolve this outside of pandas with pyreadstat by using the encoding="latin1" keyword argument

Feature Description

Keyword arguments here in pyreadstat docs
Something like this allowing to pass pyreadstat arguments
May need to handle output_format="dict"

def read_spss(
    path: str | Path,
    usecols: Sequence[str] | None = None,
    convert_categoricals: bool = True,
    dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
    **kwargs,
    ) -> DataFrame:
    ...
    df, metadata = pyreadstat.read_sav(
        stringify_path(path),
        usecols=usecols,
        apply_value_formats=convert_categoricals,
        **kwargs,
    )
    ...
    return df

Alternative Solutions

No alternative

Additional Context

No response

Metadata

Metadata

Assignees

Labels

EnhancementIO DataIO issues that don't fit into a more specific label

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions