Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 3 tasks
tinrobot2000 opened this issue Dec 6, 2023 · 2 comments · Fixed by #56434
Closed
1 of 3 tasks
Assignees
Labels
Enhancement IO Data IO issues that don't fit into a more specific label

Comments

@tinrobot2000
Copy link

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

@tinrobot2000 tinrobot2000 added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 6, 2023
@phofl phofl added IO Data IO issues that don't fit into a more specific label and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 7, 2023
@astronights
Copy link
Contributor

astronights commented Dec 30, 2023

@tinrobot2000 Please review the added PR.

@astronights
Copy link
Contributor

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants