Skip to content
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into settingwithcopywarning
# Conflicts: #	ci/code_checks.sh #	pandas/core/generic.py #	pandas/core/groupby/groupby.py #	pandas/errors/__init__.py #	pandas/tests/copy_view/test_chained_assignment_deprecation.py #	pandas/tests/copy_view/test_indexing.py #	pandas/tests/indexing/test_chaining_and_caching.py #	pandas/tests/series/test_ufunc.py
  • Loading branch information
phofl committed Feb 1, 2024
commit 9f826eec6c80c85c4edf4fca1cfec389959ceec9
210 changes: 112 additions & 98 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,104 +69,118 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
$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 (EX03)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX03 --ignore_functions \
pandas.Series.dt.day_name \
pandas.Series.str.len \
pandas.Series.cat.set_categories \
pandas.Series.plot.bar \
pandas.Series.plot.hist \
pandas.Series.plot.line \
pandas.Series.to_sql \
pandas.Series.to_latex \
pandas.errors.CategoricalConversionWarning \
pandas.errors.ChainedAssignmentError \
pandas.errors.ClosedFileError \
pandas.errors.DatabaseError \
pandas.errors.IndexingError \
pandas.errors.InvalidColumnName \
pandas.errors.NumExprClobberingError \
pandas.errors.PossibleDataLossError \
pandas.errors.PossiblePrecisionLoss \
pandas.errors.SpecificationError \
pandas.errors.UndefinedVariableError \
pandas.errors.ValueLabelTypeMismatch \
pandas.Timestamp.ceil \
pandas.Timestamp.floor \
pandas.Timestamp.round \
pandas.read_pickle \
pandas.ExcelWriter \
pandas.read_json \
pandas.io.json.build_table_schema \
pandas.DataFrame.to_latex \
pandas.io.formats.style.Styler.to_latex \
pandas.read_parquet \
pandas.DataFrame.to_sql \
pandas.read_stata \
pandas.core.resample.Resampler.pipe \
pandas.core.resample.Resampler.fillna \
pandas.core.resample.Resampler.interpolate \
pandas.plotting.scatter_matrix \
pandas.pivot \
pandas.merge_asof \
pandas.wide_to_long \
pandas.Index.rename \
pandas.Index.droplevel \
pandas.Index.isin \
pandas.CategoricalIndex.set_categories \
pandas.MultiIndex.names \
pandas.MultiIndex.droplevel \
pandas.IndexSlice \
pandas.DatetimeIndex.month_name \
pandas.DatetimeIndex.day_name \
pandas.core.window.rolling.Rolling.corr \
pandas.Grouper \
pandas.core.groupby.SeriesGroupBy.apply \
pandas.core.groupby.DataFrameGroupBy.apply \
pandas.core.groupby.SeriesGroupBy.transform \
pandas.core.groupby.SeriesGroupBy.pipe \
pandas.core.groupby.DataFrameGroupBy.pipe \
pandas.core.groupby.DataFrameGroupBy.describe \
pandas.core.groupby.DataFrameGroupBy.idxmax \
pandas.core.groupby.DataFrameGroupBy.idxmin \
pandas.core.groupby.DataFrameGroupBy.value_counts \
pandas.core.groupby.SeriesGroupBy.describe \
pandas.core.groupby.DataFrameGroupBy.boxplot \
pandas.core.groupby.DataFrameGroupBy.hist \
pandas.io.formats.style.Styler.map \
pandas.io.formats.style.Styler.apply_index \
pandas.io.formats.style.Styler.map_index \
pandas.io.formats.style.Styler.format \
pandas.io.formats.style.Styler.format_index \
pandas.io.formats.style.Styler.relabel_index \
pandas.io.formats.style.Styler.hide \
pandas.io.formats.style.Styler.set_td_classes \
pandas.io.formats.style.Styler.set_tooltips \
pandas.io.formats.style.Styler.set_uuid \
pandas.io.formats.style.Styler.pipe \
pandas.io.formats.style.Styler.highlight_between \
pandas.io.formats.style.Styler.highlight_quantile \
pandas.io.formats.style.Styler.background_gradient \
pandas.io.formats.style.Styler.text_gradient \
pandas.DataFrame.values \
pandas.DataFrame.loc \
pandas.DataFrame.iloc \
pandas.DataFrame.groupby \
pandas.DataFrame.describe \
pandas.DataFrame.skew \
pandas.DataFrame.var \
pandas.DataFrame.idxmax \
pandas.DataFrame.idxmin \
pandas.DataFrame.last \
pandas.DataFrame.pivot \
pandas.DataFrame.sort_values \
pandas.DataFrame.tz_convert \
pandas.DataFrame.tz_localize \
pandas.DataFrame.plot.bar \
pandas.DataFrame.plot.hexbin \
pandas.DataFrame.plot.hist \
pandas.DataFrame.plot.line \
pandas.DataFrame.hist \
MSG='Partially validate docstrings (PR02)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=PR02 --ignore_functions \
pandas.io.formats.style.Styler.to_excel\
pandas.CategoricalIndex.rename_categories\
pandas.CategoricalIndex.reorder_categories\
pandas.CategoricalIndex.add_categories\
pandas.CategoricalIndex.remove_categories\
pandas.CategoricalIndex.set_categories\
pandas.IntervalIndex.set_closed\
pandas.IntervalIndex.contains\
pandas.IntervalIndex.overlaps\
pandas.IntervalIndex.to_tuples\
pandas.DatetimeIndex.round\
pandas.DatetimeIndex.floor\
pandas.DatetimeIndex.ceil\
pandas.DatetimeIndex.month_name\
pandas.DatetimeIndex.day_name\
pandas.DatetimeIndex.to_period\
pandas.DatetimeIndex.std\
pandas.TimedeltaIndex.round\
pandas.TimedeltaIndex.floor\
pandas.TimedeltaIndex.ceil\
pandas.PeriodIndex\
pandas.PeriodIndex.strftime\
pandas.Series.rename_axis\
pandas.Series.dt.to_period\
pandas.Series.dt.tz_localize\
pandas.Series.dt.tz_convert\
pandas.Series.dt.strftime\
pandas.Series.dt.round\
pandas.Series.dt.floor\
pandas.Series.dt.ceil\
pandas.Series.dt.month_name\
pandas.Series.dt.day_name\
pandas.Series.str.wrap\
pandas.Series.cat.rename_categories\
pandas.Series.cat.reorder_categories\
pandas.Series.cat.add_categories\
pandas.Series.cat.remove_categories\
pandas.Series.cat.set_categories\
pandas.Series.plot\
pandas.Series.plot.bar\
pandas.Series.plot.barh\
pandas.Series.plot.line\
pandas.Series.plot.pie\
pandas.DataFrame.plot\
pandas.DataFrame.plot.bar\
pandas.DataFrame.plot.barh\
pandas.DataFrame.plot.line\
pandas.DataFrame.plot.pie\
pandas.tseries.offsets.DateOffset\
pandas.tseries.offsets.BusinessDay\
pandas.tseries.offsets.BDay\
pandas.tseries.offsets.BusinessHour\
pandas.tseries.offsets.CustomBusinessDay\
pandas.tseries.offsets.CDay\
pandas.tseries.offsets.CustomBusinessHour\
pandas.tseries.offsets.MonthEnd\
pandas.tseries.offsets.MonthBegin\
pandas.tseries.offsets.BusinessMonthEnd\
pandas.tseries.offsets.BMonthEnd\
pandas.tseries.offsets.BusinessMonthBegin\
pandas.tseries.offsets.BMonthBegin\
pandas.tseries.offsets.CustomBusinessMonthEnd\
pandas.tseries.offsets.CBMonthEnd\
pandas.tseries.offsets.CustomBusinessMonthBegin\
pandas.tseries.offsets.CBMonthBegin\
pandas.tseries.offsets.SemiMonthEnd\
pandas.tseries.offsets.SemiMonthBegin\
pandas.tseries.offsets.Week\
pandas.tseries.offsets.WeekOfMonth\
pandas.tseries.offsets.LastWeekOfMonth\
pandas.tseries.offsets.BQuarterEnd\
pandas.tseries.offsets.BQuarterBegin\
pandas.tseries.offsets.QuarterEnd\
pandas.tseries.offsets.QuarterBegin\
pandas.tseries.offsets.BYearEnd\
pandas.tseries.offsets.BYearBegin\
pandas.tseries.offsets.YearEnd\
pandas.tseries.offsets.YearBegin\
pandas.tseries.offsets.FY5253\
pandas.tseries.offsets.FY5253Quarter\
pandas.tseries.offsets.Easter\
pandas.tseries.offsets.Day\
pandas.tseries.offsets.Hour\
pandas.tseries.offsets.Minute\
pandas.tseries.offsets.Second\
pandas.tseries.offsets.Milli\
pandas.tseries.offsets.Micro\
pandas.tseries.offsets.Nano\
pandas.set_option\
pandas.Timestamp.max\
pandas.Timestamp.min\
pandas.Timestamp.resolution\
pandas.Timedelta.max\
pandas.Timedelta.min\
pandas.Timedelta.resolution\
pandas.Interval\
pandas.Grouper\
pandas.core.groupby.SeriesGroupBy.apply\
pandas.core.groupby.SeriesGroupBy.transform\
pandas.core.groupby.DataFrameGroupBy.transform\
pandas.core.groupby.DataFrameGroupBy.nth\
pandas.core.groupby.DataFrameGroupBy.rolling\
pandas.core.groupby.SeriesGroupBy.nth\
pandas.core.groupby.SeriesGroupBy.rolling\
pandas.core.groupby.DataFrameGroupBy.hist\
pandas.core.groupby.DataFrameGroupBy.plot\
pandas.core.groupby.DataFrameGroupBy.corrwith\
pandas.core.groupby.SeriesGroupBy.plot\
pandas.core.window.rolling.Rolling.quantile\
pandas.core.window.expanding.Expanding.quantile # There should be no backslash in the final line, please keep this comment in the last ignored function
RET=$(($RET + $?)) ; echo $MSG "DONE"

fi
Expand Down
7 changes: 3 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
AbstractMethodError,
ChainedAssignmentError,
InvalidIndexError,
)
from pandas.errors.cow import (
_chained_assignment_method_msg,
_chained_assignment_warning_method_msg,
_check_cacher,
Expand Down Expand Up @@ -171,10 +173,7 @@
ensure_index,
)
from pandas.core.internals import BlockManager
from pandas.core.internals.construction import (
mgr_to_mgr,
ndarray_to_mgr,
)
from pandas.core.internals.construction import ndarray_to_mgr
from pandas.core.methods.describe import describe_ndframe
from pandas.core.missing import (
clean_fill_method,
Expand Down
16 changes: 2 additions & 14 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,19 +1122,7 @@ def get_group(self, name) -> DataFrame | Series:
inds = self._get_index(name)
if not len(inds):
raise KeyError(name)

if obj is None:
indexer = inds if self.axis == 0 else (slice(None), inds)
return self._selected_obj.iloc[indexer]
else:
warnings.warn(
"obj is deprecated and will be removed in a future version. "
"Do ``df.iloc[gb.indices.get(name)]`` "
"instead of ``gb.get_group(name, obj=df)``.",
FutureWarning,
stacklevel=find_stack_level(),
)
return obj.take(inds, axis=self.axis)
return self._selected_obj.iloc[inds]

@final
def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]:
Expand Down Expand Up @@ -1772,7 +1760,7 @@ def f(g):
):
warnings.warn(
message=_apply_groupings_depr.format(type(self).__name__, "apply"),
category=FutureWarning,
category=DeprecationWarning,
stacklevel=find_stack_level(),
)
except TypeError:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import pytest

from pandas.compat import PY311
from pandas.errors import ChainedAssignmentError

from pandas import DataFrame
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/copy_view/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ def test_series_midx_tuples_slice(using_copy_on_write, warn_copy_on_write):


def test_midx_read_only_bool_indexer():
# GH#56635
def mklbl(prefix, n):
return [f"{prefix}{i}" for i in range(n)]

Expand All @@ -1041,9 +1042,11 @@ def mklbl(prefix, n):
df = DataFrame(1, index=idx, columns=cols).sort_index().sort_index(axis=1)

mask = df[("a", "foo")] == 1
expected_mask = mask.copy()
result = df.loc[pd.IndexSlice[mask, :, ["C1", "C3"]], :]
expected = df.loc[pd.IndexSlice[:, :, ["C1", "C3"]], :]
tm.assert_frame_equal(result, expected)
tm.assert_series_equal(mask, expected_mask)


def test_loc_enlarging_with_dataframe(using_copy_on_write):
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/series/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ def add3(x, y, z):
ufunc(ser, ser, df)


# TODO(CoW) see https://github.com/pandas-dev/pandas/pull/51082
@pytest.mark.skip(reason="not implemented with CoW")
@pytest.mark.xfail(reason="see https://github.com/pandas-dev/pandas/pull/51082")
def test_np_fix():
# np.fix is not a ufunc but is composed of several ufunc calls under the hood
# with `out` and `where` keywords
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.