Skip to content

Commit 699b44f

Browse files
committed
CLN: Add annotations
Add annotations Fix error message Add backward compatible reference Update what's new
1 parent e1c706c commit 699b44f

File tree

5 files changed

+47
-17
lines changed

5 files changed

+47
-17
lines changed

doc/source/whatsnew/index.rst

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ This is the list of changes to pandas between each release. For full details,
1010
see the commit logs at http://github.com/pandas-dev/pandas. For install and
1111
upgrade instructions, see :ref:`install`.
1212

13+
Version 1.1
14+
-----------
15+
16+
.. toctree::
17+
:maxdepth: 2
18+
19+
v1.1.0
20+
1321
Version 1.0
1422
-----------
1523

doc/source/whatsnew/v1.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Other enhancements
224224
- :meth:`DataFrame.sort_values` and :meth:`Series.sort_values` have gained ``ignore_index`` keyword to be able to reset index after sorting (:issue:`30114`)
225225
- :meth:`DataFrame.sort_index` and :meth:`Series.sort_index` have gained ``ignore_index`` keyword to reset index (:issue:`30114`)
226226
- :meth:`DataFrame.drop_duplicates` has gained ``ignore_index`` keyword to reset index (:issue:`30114`)
227-
- Added new writer for exporting Stata dta files in version 118 and 119, ``StataWriterUTF8``. This format supports exporting strings containing Unicode characters (:issue:`23573`)
227+
- Added new writer for exporting Stata dta files in version 118, ``StataWriter118``. This format supports exporting strings containing Unicode characters (:issue:`23573`)
228228
- :meth:`Series.map` now accepts ``collections.abc.Mapping`` subclasses as a mapper (:issue:`29733`)
229229
- The ``pandas.datetime`` class is now deprecated. Import from ``datetime`` instead (:issue:`30296`)
230230
- Added an experimental :attr:`~DataFrame.attrs` for storing global metadata about a dataset (:issue:`29062`)

doc/source/whatsnew/v1.1.0.rst

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. _whatsnew_110:
2+
3+
What's new in 1.1.0 (??)
4+
------------------------
5+
6+
Enhancements
7+
~~~~~~~~~~~~
8+
9+
Other enhancements
10+
^^^^^^^^^^^^^^^^^^
11+
12+
- Added new writer for exporting Stata dta files in version 119, ``StataWriterUTF8``. This supersedes ``StataWriter118`` which was introduced in 1.0 (:issue:`30959`)
13+
14+
Deprecations
15+
~~~~~~~~~~~~
16+
- ``StataWriter118`` is deprecated in favor of ``StataWriterUTF8`` which writes both 118 and 119 format files (:issue:`30959`).

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ def to_stata(
19451945
"""
19461946
kwargs = {}
19471947
if version not in (114, 117, 118, 119, None):
1948-
raise ValueError("Only formats 114, 117 and 118 are supported.")
1948+
raise ValueError("Only formats 114, 117, 118 and 119 are supported.")
19491949
if version == 114:
19501950
if convert_strl is not None:
19511951
raise ValueError("strl is not supported in format 114")

pandas/io/stata.py

+21-15
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
import os
1616
import struct
1717
import sys
18-
from typing import Any
18+
from typing import Any, Dict, Hashable, Optional, Sequence
1919
import warnings
2020

2121
from dateutil.relativedelta import relativedelta
2222
import numpy as np
2323

2424
from pandas._libs.lib import infer_dtype
2525
from pandas._libs.writers import max_len_string_array
26-
from pandas.util._decorators import Appender
26+
from pandas._typing import FilePathOrBuffer
27+
from pandas.util._decorators import Appender, deprecate
2728

2829
from pandas.core.dtypes.common import (
2930
ensure_object,
@@ -2696,7 +2697,7 @@ def _convert_key(self, key):
26962697

26972698
def generate_table(self):
26982699
"""
2699-
Generates the GSO lookup table for the DataFRame
2700+
Generates the GSO lookup table for the DataFrame
27002701
27012702
Returns
27022703
-------
@@ -3229,6 +3230,8 @@ class StataWriterUTF8(StataWriter117):
32293230
the version. 118 is used if data.shape[1] <= 32767, and 119 is used
32303231
for storing larger DataFrames.
32313232
3233+
.. versionadded:: 1.1.0
3234+
32323235
Returns
32333236
-------
32343237
StataWriterUTF8
@@ -3268,16 +3271,16 @@ class StataWriterUTF8(StataWriter117):
32683271

32693272
def __init__(
32703273
self,
3271-
fname,
3272-
data,
3273-
convert_dates=None,
3274-
write_index=True,
3275-
byteorder=None,
3276-
time_stamp=None,
3277-
data_label=None,
3278-
variable_labels=None,
3279-
convert_strl=None,
3280-
version=None,
3274+
fname: FilePathOrBuffer,
3275+
data: DataFrame,
3276+
convert_dates: Optional[Dict[Hashable, str]] = None,
3277+
write_index: bool = True,
3278+
byteorder: Optional[str] = None,
3279+
time_stamp: Optional[datetime.datetime] = None,
3280+
data_label: Optional[str] = None,
3281+
variable_labels: Optional[Dict[Hashable, str]] = None,
3282+
convert_strl: Optional[Sequence[Hashable]] = None,
3283+
version: Optional[int] = None,
32813284
):
32823285
if version is None:
32833286
version = 118 if data.shape[1] <= 32767 else 119
@@ -3297,7 +3300,7 @@ def __init__(
32973300
# Override version set in StataWriter117 init
32983301
self._dta_version = version
32993302

3300-
def _validate_variable_name(self, name):
3303+
def _validate_variable_name(self, name: str):
33013304
"""
33023305
Validate variable names for Stata export.
33033306
@@ -3314,7 +3317,7 @@ def _validate_variable_name(self, name):
33143317
33153318
Notes
33163319
-----
3317-
Stata 118 support most unicode characters. The only limatation is in
3320+
Stata 118 support most unicode characters. The only limitation is in
33183321
the ascii range where the characters supported are a-z, A-Z, 0-9 and _.
33193322
"""
33203323
# High code points appear to be acceptable
@@ -3329,3 +3332,6 @@ def _validate_variable_name(self, name):
33293332
name = name.replace(c, "_")
33303333

33313334
return name
3335+
3336+
3337+
StataWriter118 = deprecate("pandas.io.stata.StataWriterUTF8", StataWriterUTF8, "2.0.0")

0 commit comments

Comments
 (0)