Skip to content

Commit

Permalink
ENH: Add StataWriter 118 for unicode support
Browse files Browse the repository at this point in the history
Add StataWriter with unicode support
  • Loading branch information
bashtage committed Dec 19, 2019
1 parent e66a2c7 commit 303ba16
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 170 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Other enhancements
- The ``partition_cols`` argument in :meth:`DataFrame.to_parquet` now accepts a string (:issue:`27117`)
- :func:`to_parquet` now appropriately handles the ``schema`` argument for user defined schemas in the pyarrow engine. (:issue: `30270`)
- DataFrame constructor preserve `ExtensionArray` dtype with `ExtensionArray` (:issue:`11363`)

- Added new writer for exporting Stata dta files in version 118, ``StataWriter118``. This format supports exporting strings containing Unicode characters (:issue:`23573`)

Build Changes
^^^^^^^^^^^^^
Expand Down
11 changes: 7 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1926,14 +1926,17 @@ def to_stata(
>>> df.to_stata('animals.dta') # doctest: +SKIP
"""
kwargs = {}
if version not in (114, 117):
raise ValueError("Only formats 114 and 117 supported.")
if version not in (114, 117, 118):
raise ValueError("Only formats 114, 117 and 118 are supported.")
if version == 114:
if convert_strl is not None:
raise ValueError("strl support is only available when using format 117")
raise ValueError("strl is not supported in format 114")
from pandas.io.stata import StataWriter as statawriter
else:
from pandas.io.stata import StataWriter117 as statawriter
if version == 117:
from pandas.io.stata import StataWriter117 as statawriter
else:
from pandas.io.stata import StataWriter118 as statawriter

kwargs["convert_strl"] = convert_strl

Expand Down
Loading

0 comments on commit 303ba16

Please sign in to comment.