@@ -2221,14 +2221,14 @@ def read_stata(
22212221 iterator : bool, default False
22222222 Return StataReader object.
22232223 compression : str or dict, default 'infer'
2224- For on-the-fly decompression of on-disk data. If 'infer' and 'filepath_or_buffer' is
2225- path-like, then detect compression from the following extensions: '.gz',
2226- '.bz2', '.zip ', '.xz ', '.zst ', '.tar ', '.tar.gz ', '.tar.xz' or '.tar.bz2'
2227- (otherwise no compression).
2228- If using 'zip' or 'tar', the ZIP file must contain only one data file to be read in.
2229- Set to ``None`` for no decompression.
2230- Can also be a dict with key ``'method'`` set
2231- to one of {``'zip'``, ``'gzip'``, ``'bz2'``, ``'zstd'``, ``'xz'``, ``'tar'``} and
2224+ For on-the-fly decompression of on-disk data. If 'infer' and
2225+ 'filepath_or_buffer' is path-like, then detect compression from the
2226+ following extensions: '.gz ', '.bz2 ', '.zip ', '.xz ', '.zst ', '.tar',
2227+ '.tar.gz', '.tar.xz' or '.tar.bz2' (otherwise no compression).
2228+ If using 'zip' or 'tar', the ZIP file must contain only one
2229+ data file to be read in. Set to ``None`` for no decompression.
2230+ Can also be a dict with key ``'method'`` set to one of
2231+ {``'zip'``, ``'gzip'``, ``'bz2'``, ``'zstd'``, ``'xz'``, ``'tar'``} and
22322232 other key-value pairs are forwarded to
22332233 ``zipfile.ZipFile``, ``gzip.GzipFile``,
22342234 ``bz2.BZ2File``, ``zstandard.ZstdDecompressor``, ``lzma.LZMAFile`` or
@@ -2271,19 +2271,25 @@ def read_stata(
22712271
22722272 Creating a dummy stata for this example
22732273
2274- >>> df = pd.DataFrame({'animal': ['falcon', 'parrot', 'falcon', 'parrot'],
2275- ... 'speed': [350, 18, 361, 15]}) # doctest: +SKIP
2276- >>> df.to_stata('animals.dta') # doctest: +SKIP
2274+ >>> df = pd.DataFrame(
2275+ ... {
2276+ ... "animal": ["falcon", "parrot", "falcon", "parrot"],
2277+ ... "speed": [350, 18, 361, 15],
2278+ ... }
2279+ ... ) # doctest: +SKIP
2280+ >>> df.to_stata("animals.dta") # doctest: +SKIP
22772281
22782282 Read a Stata dta file:
22792283
2280- >>> df = pd.read_stata(' animals.dta' ) # doctest: +SKIP
2284+ >>> df = pd.read_stata(" animals.dta" ) # doctest: +SKIP
22812285
22822286 Read a Stata dta file in 10,000 line chunks:
22832287
2284- >>> values = np.random.randint(0, 10, size=(20_000, 1), dtype="uint8") # doctest: +SKIP
2288+ >>> values = np.random.randint(
2289+ ... 0, 10, size=(20_000, 1), dtype="uint8"
2290+ ... ) # doctest: +SKIP
22852291 >>> df = pd.DataFrame(values, columns=["i"]) # doctest: +SKIP
2286- >>> df.to_stata(' filename.dta' ) # doctest: +SKIP
2292+ >>> df.to_stata(" filename.dta" ) # doctest: +SKIP
22872293
22882294 >>> with pd.read_stata('filename.dta', chunksize=10000) as itr: # doctest: +SKIP
22892295 >>> for chunk in itr:
0 commit comments