Skip to content

Sync Fork from Upstream Repo #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
pandas/io/sql.py \
pandas/io/formats/format.py \
pandas/io/formats/style.py \
pandas/io/stata.py \
pandas/tseries/
RET=$(($RET + $?)) ; echo $MSG "DONE"

Expand Down
19 changes: 17 additions & 2 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,30 @@

Examples
--------

Creating a dummy stata for this example
>>> df = pd.DataFrame({{'animal': ['falcon', 'parrot', 'falcon',
... 'parrot'],
... 'speed': [350, 18, 361, 15]}})
>>> df.to_stata('animals.dta')

Read a Stata dta file:

>>> df = pd.read_stata('filename.dta')
>>> df = pd.read_stata('animals.dta')

Read a Stata dta file in 10,000 line chunks:
>>> values = np.random.randint(0, 10, size=(20_000, 1), dtype="uint8")
>>> df = pd.DataFrame(values, columns=["i"])
>>> df.to_stata('filename.dta')

>>> itr = pd.read_stata('filename.dta', chunksize=10000)
>>> for chunk in itr:
... do_something(chunk)
... # Operate on a single chunk, e.g., chunk.mean()
... pass

>>> import os
>>> os.remove("./filename.dta")
>>> os.remove("./animals.dta")
"""

_read_method_doc = f"""\
Expand Down
9 changes: 7 additions & 2 deletions pandas/tests/test_expressions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import operator
import re
import warnings

import numpy as np
import pytest
Expand Down Expand Up @@ -167,8 +168,12 @@ def testit():

op = getattr(operator, opname)

result = expr.evaluate(op, left, left, use_numexpr=True)
expected = expr.evaluate(op, left, left, use_numexpr=False)
with warnings.catch_warnings():
# array has 0s
msg = "invalid value encountered in true_divide"
warnings.filterwarnings("ignore", msg, RuntimeWarning)
result = expr.evaluate(op, left, left, use_numexpr=True)
expected = expr.evaluate(op, left, left, use_numexpr=False)
tm.assert_numpy_array_equal(result, expected)

result = expr._can_use_numexpr(op, op_str, right, right, "evaluate")
Expand Down