Skip to content

Commit a73b91f

Browse files
Fix line length errors in test_explode.py to pass pre-commit checks
1 parent 147c3d3 commit a73b91f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

pandas/tests/series/methods/test_explode.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,27 @@ def test_explode_pyarrow_non_list_type(ignore_index):
176176
expected = pd.Series([1, 2, 3], dtype="int64[pyarrow]", index=[0, 1, 2])
177177
tm.assert_series_equal(result, expected)
178178

179+
179180
def test_explode_preserves_datetime_unit():
180181
# Create datetime64[ms] array manually
181-
dt64_ms = np.array(["2020-01-01T00:00:00.000", "2020-01-01T01:00:00.000", "2020-01-01T02:00:00.000"], dtype="datetime64[ms]")
182+
dt64_ms = np.array(
183+
[
184+
"2020-01-01T00:00:00.000",
185+
"2020-01-01T01:00:00.000",
186+
"2020-01-01T02:00:00.000",
187+
],
188+
dtype="datetime64[ms]",
189+
)
182190
s = pd.Series([dt64_ms])
183191

184192
# Explode the Series
185193
result = s.explode()
186194

187195
# Ensure the dtype (including unit) is preserved
188-
assert result.dtype == dt64_ms.dtype, f"Expected dtype {dt64_ms.dtype}, got {result.dtype}"
196+
assert result.dtype == dt64_ms.dtype, (
197+
f"Expected dtype {dt64_ms.dtype}, got {result.dtype}"
198+
)
199+
189200

190201
def test_single_column_explode_preserves_datetime_unit():
191202
# Use freq in ms since unit='ms'
@@ -194,10 +205,11 @@ def test_single_column_explode_preserves_datetime_unit():
194205
result = s.explode()
195206
assert result.dtype == rng.dtype
196207

208+
197209
def test_multi_column_explode_preserves_datetime_unit():
198210
rng1 = pd.date_range("2020-01-01", periods=2, freq="3600000ms", unit="ms")
199211
rng2 = pd.date_range("2020-01-01", periods=2, freq="3600000ms", unit="ms")
200212
df = pd.DataFrame({"A": [rng1], "B": [rng2]})
201213
result = df.explode(["A", "B"])
202214
assert result["A"].dtype == rng1.dtype
203-
assert result["B"].dtype == rng2.dtype
215+
assert result["B"].dtype == rng2.dtype

0 commit comments

Comments
 (0)