Skip to content

DOC: add documentation for read_spss(#27476) #27594

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

Merged
merged 2 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/source/reference/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ SAS

read_sas

SPSS
~~~~
.. autosummary::
:toctree: api/

read_spss

SQL
~~~
.. autosummary::
Expand Down
37 changes: 37 additions & 0 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The pandas I/O API is a set of top level ``reader`` functions accessed like
binary;`Msgpack <https://msgpack.org/index.html>`__;:ref:`read_msgpack<io.msgpack>`;:ref:`to_msgpack<io.msgpack>`
binary;`Stata <https://en.wikipedia.org/wiki/Stata>`__;:ref:`read_stata<io.stata_reader>`;:ref:`to_stata<io.stata_writer>`
binary;`SAS <https://en.wikipedia.org/wiki/SAS_(software)>`__;:ref:`read_sas<io.sas_reader>`;
binary;`SPSS <https://en.wikipedia.org/wiki/SPSS>`__;:ref:`read_spss<io.spss_reader>`;
binary;`Python Pickle Format <https://docs.python.org/3/library/pickle.html>`__;:ref:`read_pickle<io.pickle>`;:ref:`to_pickle<io.pickle>`
SQL;`SQL <https://en.wikipedia.org/wiki/SQL>`__;:ref:`read_sql<io.sql>`;:ref:`to_sql<io.sql>`
SQL;`Google Big Query <https://en.wikipedia.org/wiki/BigQuery>`__;:ref:`read_gbq<io.bigquery>`;:ref:`to_gbq<io.bigquery>`
Expand Down Expand Up @@ -5477,6 +5478,42 @@ web site.

No official documentation is available for the SAS7BDAT format.

.. _io.spss:

.. _io.spss_reader:

SPSS formats
------------

The top-level function :func:`read_spss` can read (but not write) SPSS
`sav` (.sav) and `zsav` (.zsav) format files(since *v0.25.0*).

SPSS files contain column names. By default the
whole file is read, categorical columns are converted into ``pd.Categorical``
and a ``DataFrame`` with all columns is returned.

Specify a ``usecols`` to obtain a subset of columns. Specify ``convert_categoricals=False``
to avoid converting categorical columns into ``pd.Categorical``.

Read a spss file:

.. code-block:: python

df = pd.read_spss('spss_data.zsav')

Extract a subset of columns ``usecols`` from SPSS file and
avoid converting categorical columns into ``pd.Categorical``:

.. code-block:: python

df = pd.read_spss('spss_data.zsav', usecols=['foo', 'bar'],
convert_categoricals=False)

More info_ about the sav and zsav file format is available from the IBM
web site.

.. _info: https://www.ibm.com/support/knowledgecenter/en/SSLVMB_22.0.0/com.ibm.spss.statistics.help/spss/base/savedatatypes.htm

.. _io.other:

Other file formats
Expand Down