diff --git a/ci/code_checks.sh b/ci/code_checks.sh index ee989604534f5..c0a26edd230eb 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -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 diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 42ebfea1f370e..239fe9f94cdf3 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -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`: @@ -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')] @@ -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 @@ -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] @@ -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). @@ -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 diff --git a/pandas/io/json/_json.py b/pandas/io/json/_json.py index 4c490c6b2cda2..594fb8651f8f0 100644 --- a/pandas/io/json/_json.py +++ b/pandas/io/json/_json.py @@ -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 @@ -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 @@ -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