Skip to content

Commit 5118a6e

Browse files
committed
remove from exclusions + cleanup
1 parent 30589f7 commit 5118a6e

21 files changed

+82
-77
lines changed

asv_bench/benchmarks/attrs_caching.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def setup(self):
1515
self.cur_index = self.df.index
1616

1717
def time_get_index(self):
18-
self.foo = self.df.index
18+
self.foo_index = self.df.index
1919

2020
def time_set_index(self):
2121
self.df.index = self.cur_index

pandas/io/formats/style.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3209,7 +3209,7 @@ def set_properties(self, subset: Subset | None = None, **kwargs) -> Styler:
32093209
return self.applymap(lambda x: values, subset=subset)
32103210

32113211
@Substitution(subset=subset)
3212-
def bar(
3212+
def barchart(
32133213
self,
32143214
subset: Subset | None = None,
32153215
axis: Axis | None = 0,
@@ -4216,7 +4216,7 @@ def css_calc(x, left: float, right: float, align: str, color: str | list | tuple
42164216
rgbas = None
42174217
if cmap is not None:
42184218
# use the matplotlib colormap input
4219-
with _mpl(Styler.bar) as (plt, mpl):
4219+
with _mpl(Styler.barchart) as (plt, mpl):
42204220
from pandas.plotting._matplotlib.compat import mpl_ge_3_6_0
42214221

42224222
cmap = (

pandas/plotting/_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ def line(self, x=None, y=None, **kwargs) -> PlotAccessor:
11311131
)
11321132
@Substitution(kind="bar")
11331133
@Appender(_bar_or_line_doc)
1134-
def bar(self, x=None, y=None, **kwargs) -> PlotAccessor:
1134+
def barplot(self, x=None, y=None, **kwargs) -> PlotAccessor:
11351135
"""
11361136
Vertical bar plot.
11371137

pandas/tests/apply/test_frame_apply.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1509,10 +1509,10 @@ def test_aggregation_func_column_order():
15091509
columns=("item", "att1", "att2", "att3"),
15101510
)
15111511

1512-
def foo(s):
1512+
def sum_div2(s):
15131513
return s.sum() / 2
15141514

1515-
aggs = ["sum", foo, "count", "min"]
1515+
aggs = ["sum", sum_div2, "count", "min"]
15161516
with tm.assert_produces_warning(
15171517
FutureWarning, match=r"\['item'\] did not aggregate successfully"
15181518
):
@@ -1524,7 +1524,7 @@ def foo(s):
15241524
"att2": [18.0, 9.0, 6.0, 0.0],
15251525
"att3": [17.0, 8.5, 6.0, 0.0],
15261526
},
1527-
index=["sum", "foo", "count", "min"],
1527+
index=["sum", "sum_div2", "count", "min"],
15281528
)
15291529
tm.assert_frame_equal(result, expected)
15301530

@@ -1545,13 +1545,13 @@ def test_nuisance_depr_passes_through_warnings():
15451545
# sure if some other warnings were raised, they get passed through to
15461546
# the user.
15471547

1548-
def foo(x):
1548+
def expected_warning(x):
15491549
warnings.warn("Hello, World!")
15501550
return x.sum()
15511551

15521552
df = DataFrame({"a": [1, 2, 3]})
15531553
with tm.assert_produces_warning(UserWarning, match="Hello, World!"):
1554-
df.agg([foo])
1554+
df.agg([expected_warning])
15551555

15561556

15571557
def test_apply_type():

pandas/tests/base/test_constructors.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ class Delegator:
4646
_properties = ["foo"]
4747
_methods = ["bar"]
4848

49-
def _set_foo(self, value):
50-
self.foo = value
49+
def _set_value(self, value):
50+
self.value = value
5151

52-
def _get_foo(self):
53-
return self.foo
52+
def _get_value(self):
53+
return self.value
5454

55-
foo = property(_get_foo, _set_foo, doc="foo property")
55+
value = property(_get_value, _set_value, doc="foo property")
5656

57-
def bar(self, *args, **kwargs):
57+
def test_method(self, *args, **kwargs):
5858
"""a test bar method"""
5959
pass
6060

@@ -80,15 +80,15 @@ def test_invalid_delegation(self):
8080

8181
msg = "You cannot access the property foo"
8282
with pytest.raises(TypeError, match=msg):
83-
delegate.foo
83+
delegate.inaccesible
8484

8585
msg = "The property foo cannot be set"
8686
with pytest.raises(TypeError, match=msg):
87-
delegate.foo = 5
87+
delegate.inaccesible = 5
8888

8989
msg = "You cannot access the property foo"
9090
with pytest.raises(TypeError, match=msg):
91-
delegate.foo()
91+
delegate.inaccesible()
9292

9393
@pytest.mark.skipif(PYPY, reason="not relevant for PyPy")
9494
def test_memory_usage(self):

pandas/tests/dtypes/test_inference.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,16 @@ def test_is_list_like_disallow_sets(maybe_list_like):
203203
def test_is_list_like_recursion():
204204
# GH 33721
205205
# interpreter would crash with SIGABRT
206-
def foo():
206+
def list_like():
207207
inference.is_list_like([])
208-
foo()
208+
list_like()
209209

210210
rec_limit = sys.getrecursionlimit()
211211
try:
212212
# Limit to avoid stack overflow on Windows CI
213213
sys.setrecursionlimit(100)
214214
with tm.external_error_raised(RecursionError):
215-
foo()
215+
list_like()
216216
finally:
217217
sys.setrecursionlimit(rec_limit)
218218

pandas/tests/frame/test_subclass.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ def test_subclass_attr_err_propagation(self):
138138
# GH 11808
139139
class A(DataFrame):
140140
@property
141-
def bar(self):
141+
def nonexistence(self):
142142
return self.i_dont_exist
143143

144144
with pytest.raises(AttributeError, match=".*i_dont_exist.*"):
145-
A().bar
145+
A().nonexistence
146146

147147
def test_subclass_align(self):
148148
# GH 12983

pandas/tests/groupby/aggregate/test_aggregate.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,15 @@ def test_aggregate_item_by_item(df):
283283

284284
aggfun_0 = lambda ser: ser.size
285285
result = grouped.agg(aggfun_0)
286-
foo = (df.A == "foo").sum()
287-
bar = (df.A == "bar").sum()
286+
foosum = (df.A == "foo").sum()
287+
barsum = (df.A == "bar").sum()
288288
K = len(result.columns)
289289

290290
# GH5782
291-
exp = Series(np.array([foo] * K), index=list("BCD"), name="foo")
291+
exp = Series(np.array([foosum] * K), index=list("BCD"), name="foo")
292292
tm.assert_series_equal(result.xs("foo"), exp)
293293

294-
exp = Series(np.array([bar] * K), index=list("BCD"), name="bar")
294+
exp = Series(np.array([barsum] * K), index=list("BCD"), name="bar")
295295
tm.assert_almost_equal(result.xs("bar"), exp)
296296

297297
def aggfun_1(ser):
@@ -420,10 +420,10 @@ def test_more_flexible_frame_multi_function(df):
420420
expected = grouped.aggregate({"C": np.mean, "D": [np.mean, np.std]})
421421
tm.assert_frame_equal(result, expected)
422422

423-
def foo(x):
423+
def numpymean(x):
424424
return np.mean(x)
425425

426-
def bar(x):
426+
def numpystd(x):
427427
return np.std(x, ddof=1)
428428

429429
# this uses column selection & renaming
@@ -433,7 +433,7 @@ def bar(x):
433433
grouped.aggregate(d)
434434

435435
# But without renaming, these functions are OK
436-
d = {"C": [np.mean], "D": [foo, bar]}
436+
d = {"C": [np.mean], "D": [numpymean, numpystd]}
437437
grouped.aggregate(d)
438438

439439

pandas/tests/groupby/test_groupby.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@ def freduce(group):
15791579
assert group.name is not None
15801580
return group.sum()
15811581

1582-
def foo(x):
1582+
def freducex(x):
15831583
return freduce(x)
15841584

15851585
grouped = df.groupby(grouper, group_keys=False)
@@ -1592,7 +1592,7 @@ def foo(x):
15921592

15931593
grouped["C"].apply(f)
15941594
grouped["C"].aggregate(freduce)
1595-
grouped["C"].aggregate([freduce, foo])
1595+
grouped["C"].aggregate([freduce, freducex])
15961596
grouped["C"].transform(f)
15971597

15981598

pandas/tests/indexes/multi/test_integrity.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,14 @@ def test_level_setting_resets_attributes():
233233

234234
def test_rangeindex_fallback_coercion_bug():
235235
# GH 12893
236-
foo = pd.DataFrame(np.arange(100).reshape((10, 10)))
237-
bar = pd.DataFrame(np.arange(100).reshape((10, 10)))
238-
df = pd.concat({"foo": foo.stack(), "bar": bar.stack()}, axis=1)
236+
df1 = pd.DataFrame(np.arange(100).reshape((10, 10)))
237+
df2 = pd.DataFrame(np.arange(100).reshape((10, 10)))
238+
df = pd.concat({"df1": df1.stack(), "df2": df2.stack()}, axis=1)
239239
df.index.names = ["fizz", "buzz"]
240240

241241
str(df)
242242
expected = pd.DataFrame(
243-
{"bar": np.arange(100), "foo": np.arange(100)},
243+
{"df2": np.arange(100), "df1": np.arange(100)},
244244
index=MultiIndex.from_product([range(10), range(10)], names=["fizz", "buzz"]),
245245
)
246246
tm.assert_frame_equal(df, expected, check_like=True)

pandas/tests/io/formats/style/test_style.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,10 @@ def test_apply_dataframe_return(self, index, columns):
657657
)
658658
@pytest.mark.parametrize("axis", [0, 1])
659659
def test_apply_subset(self, slice_, axis, df):
660-
def h(x, foo="bar"):
661-
return Series(f"color: {foo}", index=x.index, name=x.name)
660+
def h(x, color="bar"):
661+
return Series(f"color: {color}", index=x.index, name=x.name)
662662

663-
result = df.style.apply(h, axis=axis, subset=slice_, foo="baz")._compute().ctx
663+
result = df.style.apply(h, axis=axis, subset=slice_, color="baz")._compute().ctx
664664
expected = {
665665
(r, c): [("color", "baz")]
666666
for r, row in enumerate(df.index)

pandas/tests/io/test_sql.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -2181,26 +2181,26 @@ def test_connectable_issue_example(self):
21812181
# https://github.com/pandas-dev/pandas/issues/10104
21822182
from sqlalchemy.engine import Engine
21832183

2184-
def foo(connection):
2184+
def test_select(connection):
21852185
query = "SELECT test_foo_data FROM test_foo_data"
21862186
return sql.read_sql_query(query, con=connection)
21872187

2188-
def bar(connection, data):
2188+
def test_append(connection, data):
21892189
data.to_sql(name="test_foo_data", con=connection, if_exists="append")
21902190

2191-
def baz(conn):
2191+
def test_connectable(conn):
21922192
# https://github.com/sqlalchemy/sqlalchemy/commit/
21932193
# 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973
2194-
foo_data = foo(conn)
2195-
bar(conn, foo_data)
2194+
foo_data = test_select(conn)
2195+
test_append(conn, foo_data)
21962196

21972197
def main(connectable):
21982198
if isinstance(connectable, Engine):
21992199
with connectable.connect() as conn:
22002200
with conn.begin():
2201-
baz(conn)
2201+
test_connectable(conn)
22022202
else:
2203-
baz(connectable)
2203+
test_connectable(connectable)
22042204

22052205
assert (
22062206
DataFrame({"test_foo_data": [0, 1, 2]}).to_sql("test_foo_data", self.conn)
@@ -2373,21 +2373,21 @@ def test_row_object_is_named_tuple(self):
23732373
class Test(BaseModel):
23742374
__tablename__ = "test_frame"
23752375
id = Column(Integer, primary_key=True)
2376-
foo = Column(String(50))
2376+
string_column = Column(String(50))
23772377

23782378
BaseModel.metadata.create_all(self.conn)
23792379
Session = sessionmaker(bind=self.conn)
23802380
with Session() as session:
2381-
df = DataFrame({"id": [0, 1], "foo": ["hello", "world"]})
2381+
df = DataFrame({"id": [0, 1], "string_column": ["hello", "world"]})
23822382
assert (
23832383
df.to_sql("test_frame", con=self.conn, index=False, if_exists="replace")
23842384
== 2
23852385
)
23862386
session.commit()
2387-
foo = session.query(Test.id, Test.foo)
2388-
df = DataFrame(foo)
2387+
test_query = session.query(Test.id, Test.string_column)
2388+
df = DataFrame(test_query)
23892389

2390-
assert list(df.columns) == ["id", "foo"]
2390+
assert list(df.columns) == ["id", "string_column"]
23912391

23922392

23932393
class _TestMySQLAlchemy:

pandas/tests/resample/test_period_index.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,11 @@ def test_resample_with_dst_time_change(self):
605605

606606
def test_resample_bms_2752(self):
607607
# GH2753
608-
foo = Series(index=pd.bdate_range("20000101", "20000201"), dtype=np.float64)
609-
res1 = foo.resample("BMS").mean()
610-
res2 = foo.resample("BMS").mean().resample("B").mean()
608+
timeseries = Series(
609+
index=pd.bdate_range("20000101", "20000201"), dtype=np.float64
610+
)
611+
res1 = timeseries.resample("BMS").mean()
612+
res2 = timeseries.resample("BMS").mean().resample("B").mean()
611613
assert res1.index[0] == Timestamp("20000103")
612614
assert res1.index[0] == res2.index[0]
613615

pandas/tests/reshape/concat/test_empty.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ class TestEmptyConcat:
1616
def test_handle_empty_objects(self, sort):
1717
df = DataFrame(np.random.randn(10, 4), columns=list("abcd"))
1818

19-
baz = df[:5].copy()
20-
baz["foo"] = "bar"
19+
dfcopy = df[:5].copy()
20+
dfcopy["foo"] = "bar"
2121
empty = df[5:5]
2222

23-
frames = [baz, empty, empty, df[5:]]
23+
frames = [dfcopy, empty, empty, df[5:]]
2424
concatted = concat(frames, axis=0, sort=sort)
2525

2626
expected = df.reindex(columns=["a", "b", "c", "d", "foo"])

pandas/tests/reshape/concat/test_series.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,26 @@ def test_concat_series_name_npscalar_tuple(self, s1name, s2name):
120120

121121
def test_concat_series_partial_columns_names(self):
122122
# GH10698
123-
foo = Series([1, 2], name="foo")
124-
bar = Series([1, 2])
125-
baz = Series([4, 5])
123+
foo_series = Series([1, 2], name="foo")
124+
bar_series = Series([1, 2])
125+
baz_series = Series([4, 5])
126126

127-
result = concat([foo, bar, baz], axis=1)
127+
result = concat([foo_series, bar_series, baz_series], axis=1)
128128
expected = DataFrame(
129129
{"foo": [1, 2], 0: [1, 2], 1: [4, 5]}, columns=["foo", 0, 1]
130130
)
131131
tm.assert_frame_equal(result, expected)
132132

133-
result = concat([foo, bar, baz], axis=1, keys=["red", "blue", "yellow"])
133+
result = concat(
134+
[foo_series, bar_series, baz_series], axis=1, keys=["red", "blue", "yellow"]
135+
)
134136
expected = DataFrame(
135137
{"red": [1, 2], "blue": [1, 2], "yellow": [4, 5]},
136138
columns=["red", "blue", "yellow"],
137139
)
138140
tm.assert_frame_equal(result, expected)
139141

140-
result = concat([foo, bar, baz], axis=1, ignore_index=True)
142+
result = concat([foo_series, bar_series, baz_series], axis=1, ignore_index=True)
141143
expected = DataFrame({0: [1, 2], 1: [1, 2], 2: [4, 5]})
142144
tm.assert_frame_equal(result, expected)
143145

pandas/tests/reshape/test_pivot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2106,9 +2106,9 @@ def test_pivot_table_no_column_raises(self):
21062106
def agg(arr):
21072107
return np.mean(arr)
21082108

2109-
foo = DataFrame({"X": [0, 0, 1, 1], "Y": [0, 1, 0, 1], "Z": [10, 20, 30, 40]})
2109+
df = DataFrame({"X": [0, 0, 1, 1], "Y": [0, 1, 0, 1], "Z": [10, 20, 30, 40]})
21102110
with pytest.raises(KeyError, match="notpresent"):
2111-
foo.pivot_table("notpresent", "X", "Y", aggfunc=agg)
2111+
df.pivot_table("notpresent", "X", "Y", aggfunc=agg)
21122112

21132113
def test_pivot_table_multiindex_columns_doctest_case(self):
21142114
# The relevant characteristic is that the call

0 commit comments

Comments
 (0)