Skip to content

Commit 5eba291

Browse files
committed
Refactor test_scatter_line_xticks to simplify DataFrame creation
The DataFrame creation in the test has been streamlined for clarity and conciseness by replacing the loop with a list comprehension. This improves code readability and maintains the same functionality.
1 parent 3cdd854 commit 5eba291

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pandas/tests/plotting/frame/test_frame.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,10 @@ def test_scatter_on_datetime_time_data(self):
849849

850850
def test_scatter_line_xticks(self):
851851
# GH#61005
852-
datetime_list = [datetime(year=2025, month=1, day=1, hour=n) for n in range(3)]
853-
df = DataFrame(columns=["datetime", "y"])
854-
for i, n in enumerate(datetime_list):
855-
df.loc[len(df)] = [n, i]
852+
df = DataFrame(
853+
[(datetime(year=2025, month=1, day=1, hour=n), n) for n in range(3)],
854+
columns=["datetime", "y"],
855+
)
856856
fig, ax = plt.subplots(2, sharex=True)
857857
df.plot.scatter(x="datetime", y="y", ax=ax[0])
858858
scatter_xticks = ax[0].get_xticks()

0 commit comments

Comments
 (0)