Skip to content
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
12 changes: 2 additions & 10 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,8 @@ fi
### DOCSTRINGS ###
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Validate docstrings (EX01, EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT02, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01,EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Partially validate docstrings (EX03)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX03 --ignore_functions \
pandas.Series.plot.line \
pandas.Series.to_sql \
pandas.read_json \
pandas.DataFrame.to_sql # There should be no backslash in the final line, please keep this comment in the last ignored function
MSG='Validate docstrings (EX01, EX03, EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT02, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01,EX03,EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Partially validate docstrings (PR02)' ; echo $MSG
Expand Down
16 changes: 9 additions & 7 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2999,7 +2999,7 @@ def to_sql(
3
>>> from sqlalchemy import text
>>> with engine.connect() as conn:
... conn.execute(text("SELECT * FROM users")).fetchall()
... conn.execute(text("SELECT * FROM users")).fetchall()
[(0, 'User 1'), (1, 'User 2'), (2, 'User 3')]

An `sqlalchemy.engine.Connection` can also be passed to `con`:
Expand All @@ -3016,7 +3016,7 @@ def to_sql(
>>> df2.to_sql(name='users', con=engine, if_exists='append')
2
>>> with engine.connect() as conn:
... conn.execute(text("SELECT * FROM users")).fetchall()
... conn.execute(text("SELECT * FROM users")).fetchall()
[(0, 'User 1'), (1, 'User 2'), (2, 'User 3'),
(0, 'User 4'), (1, 'User 5'), (0, 'User 6'),
(1, 'User 7')]
Expand All @@ -3027,7 +3027,7 @@ def to_sql(
... index_label='id')
2
>>> with engine.connect() as conn:
... conn.execute(text("SELECT * FROM users")).fetchall()
... conn.execute(text("SELECT * FROM users")).fetchall()
[(0, 'User 6'), (1, 'User 7')]

Use ``method`` to define a callable insertion method to do nothing
Expand All @@ -3040,13 +3040,14 @@ def to_sql(
... stmt = insert(table.table).values(data).on_conflict_do_nothing(index_elements=["a"])
... result = conn.execute(stmt)
... return result.rowcount
>>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", method=insert_on_conflict_nothing) # doctest: +SKIP
>>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", # noqa: F821
... method=insert_on_conflict_nothing) # doctest: +SKIP
0

For MySQL, a callable to update columns ``b`` and ``c`` if there's a conflict
on a primary key.

>>> from sqlalchemy.dialects.mysql import insert
>>> from sqlalchemy.dialects.mysql import insert # noqa: F811
>>> def insert_on_conflict_update(table, conn, keys, data_iter):
... # update columns "b" and "c" on primary key conflict
... data = [dict(zip(keys, row)) for row in data_iter]
Expand All @@ -3057,7 +3058,8 @@ def to_sql(
... stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c)
... result = conn.execute(stmt)
... return result.rowcount
>>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", method=insert_on_conflict_update) # doctest: +SKIP
>>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", # noqa: F821
... method=insert_on_conflict_update) # doctest: +SKIP
2

Specify the dtype (especially useful for integers with missing values).
Expand All @@ -3078,7 +3080,7 @@ def to_sql(
3

>>> with engine.connect() as conn:
... conn.execute(text("SELECT * FROM integers")).fetchall()
... conn.execute(text("SELECT * FROM integers")).fetchall()
[(1,), (None,), (2,)]
""" # noqa: E501
from pandas.io import sql
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/json/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def read_json(
"data":[["a","b"],["c","d"]]\
}}\
'
>>> pd.read_json(StringIO(_), orient='split')
>>> pd.read_json(StringIO(_), orient='split') # noqa: F821
col 1 col 2
row 1 a b
row 2 c d
Expand All @@ -727,7 +727,7 @@ def read_json(
>>> df.to_json(orient='index')
'{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}'

>>> pd.read_json(StringIO(_), orient='index')
>>> pd.read_json(StringIO(_), orient='index') # noqa: F821
col 1 col 2
row 1 a b
row 2 c d
Expand All @@ -737,7 +737,7 @@ def read_json(

>>> df.to_json(orient='records')
'[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]'
>>> pd.read_json(StringIO(_), orient='records')
>>> pd.read_json(StringIO(_), orient='records') # noqa: F821
col 1 col 2
0 a b
1 c d
Expand Down