Skip to content

MAINT: Clarify supported Stata dta versions #34116

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 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ Other enhancements
- :meth:`~pandas.core.resample.Resampler.interpolate` now supports SciPy interpolation method :class:`scipy.interpolate.CubicSpline` as method ``cubicspline`` (:issue:`33670`)
- The ``ExtensionArray`` class has now an :meth:`~pandas.arrays.ExtensionArray.equals`
method, similarly to :meth:`Series.equals` (:issue:`27081`).
-
- The minimum suppported dta version has increased to 105 in :meth:`~pandas.io.stata.read_stata` and :class:`~pandas.io.stata.StataReader` (:issue:`26667`).


.. ---------------------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

_version_error = (
"Version of given Stata file is {version}. pandas supports importing "
"versions 104, 105, 108, 111 (Stata 7SE), 113 (Stata 8/9), "
"versions 105, 108, 111 (Stata 7SE), 113 (Stata 8/9), "
"114 (Stata 10/11), 115 (Stata 12), 117 (Stata 13), 118 (Stata 14/15/16),"
"and 119 (Stata 15/16, over 32,767 variables)."
)
Expand Down Expand Up @@ -888,8 +888,8 @@ def __init__(self):
98: 251, # byte
105: 252, # int
108: 253, # long
102: 254 # float
# don't know old code for double
102: 254, # float
100: 255, # double
}

# These missing values are the generic '.' in Stata, and are used
Expand Down
Binary file added pandas/tests/io/data/stata/stata-compat-105.dta
Binary file not shown.
Binary file added pandas/tests/io/data/stata/stata-compat-108.dta
Binary file not shown.
Binary file added pandas/tests/io/data/stata/stata-compat-111.dta
Binary file not shown.
Binary file added pandas/tests/io/data/stata/stata-compat-113.dta
Binary file not shown.
Binary file added pandas/tests/io/data/stata/stata-compat-114.dta
Binary file not shown.
Binary file added pandas/tests/io/data/stata/stata-compat-118.dta
Binary file not shown.
10 changes: 10 additions & 0 deletions pandas/tests/io/test_stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1853,3 +1853,13 @@ def test_writer_118_exceptions(self):
with tm.ensure_clean() as path:
with pytest.raises(ValueError, match="You must use version 119"):
StataWriterUTF8(path, df, version=118)


@pytest.mark.parametrize("version", [105, 108, 111, 113, 114])
def test_backward_compat(version, datapath):
data_base = datapath("io", "data", "stata")
ref = os.path.join(data_base, f"stata-compat-118.dta")
old = os.path.join(data_base, f"stata-compat-{version}.dta")
expected = pd.read_stata(ref)
old_dta = pd.read_stata(old)
tm.assert_frame_equal(old_dta, expected, check_dtype=False)