File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -6114,6 +6114,13 @@ values will have ``object`` data type.
61146114 ``int64 `` for all integer types and ``float64 `` for floating point data. By default,
61156115 the Stata data types are preserved when importing.
61166116
6117+ .. note ::
6118+
6119+ All :class: `~pandas.io.stata.StataReader ` objects, whether created by :func: `~pandas.read_stata `
6120+ (when using ``iterator=True `` or ``chunksize ``) or instantiated by hand, must be closed by
6121+ calling :meth: `~pandas.io.stata.StataReader.close ` (or by using the ``with `` statement, as
6122+ in the examples above) to avoid leaking file handles.
6123+
61176124.. ipython :: python
61186125 :suppress:
61196126
Original file line number Diff line number Diff line change 183183>>> df = pd.DataFrame(values, columns=["i"]) # doctest: +SKIP
184184>>> df.to_stata('filename.dta') # doctest: +SKIP
185185
186- >>> itr = pd.read_stata('filename.dta', chunksize=10000) # doctest: +SKIP
187- >>> for chunk in itr:
188- ... # Operate on a single chunk, e.g., chunk.mean()
189- ... pass # doctest: +SKIP
186+ >>> with pd.read_stata('filename.dta', chunksize=10000) as itr: # doctest: +SKIP
187+ >>> for chunk in itr:
188+ ... # Operate on a single chunk, e.g., chunk.mean()
189+ ... pass # doctest: +SKIP
190190"""
191191
192192_read_method_doc = f"""\
You can’t perform that action at this time.
0 commit comments