File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -6097,6 +6097,14 @@ values will have ``object`` data type.
6097
6097
``int64 `` for all integer types and ``float64 `` for floating point data. By default,
6098
6098
the Stata data types are preserved when importing.
6099
6099
6100
+ .. note ::
6101
+
6102
+ All :class: `~pandas.io.stata.StataReader ` objects, whether created by :func: `~pandas.read_stata `
6103
+ (when using ``iterator=True `` or ``chunksize ``) or instantiated by hand, must be used as context
6104
+ managers (e.g. the ``with `` statement).
6105
+ The :meth: `~pandas.io.stata.StataReader.close ` method is available, but is unsupported, not part
6106
+ of the public API, and may be removed in the future.
6107
+
6100
6108
.. ipython :: python
6101
6109
:suppress:
6102
6110
Original file line number Diff line number Diff line change 182
182
>>> df = pd.DataFrame(values, columns=["i"]) # doctest: +SKIP
183
183
>>> df.to_stata('filename.dta') # doctest: +SKIP
184
184
185
- >>> itr = pd.read_stata('filename.dta', chunksize=10000) # doctest: +SKIP
186
- >>> for chunk in itr:
187
- ... # Operate on a single chunk, e.g., chunk.mean()
188
- ... pass # doctest: +SKIP
185
+ >>> with pd.read_stata('filename.dta', chunksize=10000) as itr: # doctest: +SKIP
186
+ >>> for chunk in itr:
187
+ ... # Operate on a single chunk, e.g., chunk.mean()
188
+ ... pass # doctest: +SKIP
189
189
"""
190
190
191
191
_read_method_doc = f"""\
You can’t perform that action at this time.
0 commit comments