Skip to content

Commit d0902f0

Browse files
CLN: Fix issues reported by pre-commit hooks
1 parent 4558733 commit d0902f0

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

pandas/tests/reshape/test_pivot.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,9 +2832,12 @@ def test_pivot_margins_with_none_index(self):
28322832
def test_pivot_with_pyarrow_categorical(self):
28332833
# GH#53051
28342834

2835-
# Create dataframe with categorical colum
2835+
# Create dataframe with categorical column
28362836
df = (
2837-
pd.DataFrame([("A", 1), ("B", 2), ("C", 3)], columns=["string_column", "number_column"])
2837+
DataFrame(
2838+
[("A", 1), ("B", 2), ("C", 3)],
2839+
columns=["string_column", "number_column"],
2840+
)
28382841
.astype({"string_column": "string", "number_column": "float32"})
28392842
.astype({"string_column": "category", "number_column": "float32"})
28402843
)
@@ -2845,25 +2848,18 @@ def test_pivot_with_pyarrow_categorical(self):
28452848
buffer.seek(0) # Reset buffer position
28462849
df = pd.read_parquet(buffer, dtype_backend="pyarrow")
28472850

2848-
28492851
# Check that pivot works
28502852
df = df.pivot(columns=["string_column"], values=["number_column"])
28512853

28522854
# Assert that values of result are correct to prevent silent failure
2853-
multi_index = pd.MultiIndex.from_arrays(
2854-
[
2855-
["number_column", "number_column", "number_column"],
2856-
["A", "B", "C"]
2857-
],
2858-
names=(None, "string_column")
2855+
multi_index = MultiIndex.from_arrays(
2856+
[["number_column", "number_column", "number_column"], ["A", "B", "C"]],
2857+
names=(None, "string_column"),
28592858
)
2860-
df_expected = pd.DataFrame(
2861-
[
2862-
[1.0, np.nan, np.nan],
2863-
[np.nan, 2.0, np.nan],
2864-
[np.nan, np.nan, 3.0]
2865-
],
2866-
columns=multi_index
2859+
df_expected = DataFrame(
2860+
[[1.0, np.nan, np.nan], [np.nan, 2.0, np.nan], [np.nan, np.nan, 3.0]],
2861+
columns=multi_index,
2862+
)
2863+
tm.assert_frame_equal(
2864+
df, df_expected, check_dtype=False, check_column_type=False
28672865
)
2868-
tm.assert_frame_equal(df, df_expected, check_dtype=False, check_column_type=False)
2869-

pandas/tests/test_multilevel.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,12 @@ def test_multiindex_dt_with_nan(self):
322322
def test_multiindex_with_pyarrow_categorical(self):
323323
# GH#53051
324324

325-
# Create dataframe with categorical colum
325+
# Create dataframe with categorical column
326326
df = (
327-
pd.DataFrame([("A", 1), ("B", 2), ("C", 3)], columns=["string_column", "number_column"])
327+
DataFrame(
328+
[("A", 1), ("B", 2), ("C", 3)],
329+
columns=["string_column", "number_column"],
330+
)
328331
.astype({"string_column": "string", "number_column": "float32"})
329332
.astype({"string_column": "category", "number_column": "float32"})
330333
)
@@ -335,7 +338,6 @@ def test_multiindex_with_pyarrow_categorical(self):
335338
buffer.seek(0) # Reset buffer position
336339
df = pd.read_parquet(buffer, dtype_backend="pyarrow")
337340

338-
339341
# Check that index can be set
340342
df.set_index(["string_column", "number_column"])
341343

0 commit comments

Comments
 (0)