Skip to content

Commit 22d3dc9

Browse files
author
Marco Gorelli
committed
👌 simplify , use fixture in test
1 parent a348f91 commit 22d3dc9

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

pandas/core/frame.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6747,7 +6747,6 @@ def append(self, other, ignore_index=False, verify_integrity=False, sort=False):
67476747
)
67486748

67496749
index = Index([other.name], name=self.index.name)
6750-
67516750
idx_diff = other.index.difference(self.columns)
67526751
try:
67536752
combined_columns = self.columns.append(idx_diff)
@@ -6756,8 +6755,8 @@ def append(self, other, ignore_index=False, verify_integrity=False, sort=False):
67566755
other = (
67576756
other.reindex(combined_columns, copy=False)
67586757
.to_frame()
6759-
.T.rename_axis(index.names)
6760-
._convert(datetime=True, timedelta=True)
6758+
.T.infer_objects()
6759+
.rename_axis(index.names)
67616760
)
67626761
if not self.columns.equals(combined_columns):
67636762
self = self.reindex(columns=combined_columns)

pandas/tests/frame/test_combine_concat.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import numpy as np
44
import pytest
5-
import pytz
65

76
import pandas as pd
87
from pandas import DataFrame, Index, Series, Timestamp, date_range
@@ -290,17 +289,14 @@ def test_append_dtypes(self):
290289
tm.assert_frame_equal(result, expected)
291290

292291
@pytest.mark.parametrize(
293-
"timestamp, timezone",
294-
[
295-
("2019-07-19 07:04:57+0100", pytz.FixedOffset(60)),
296-
("2019-07-19 07:04:57", None),
297-
],
292+
"timestamp", ["2019-07-19 07:04:57+0100", "2019-07-19 07:04:57"]
298293
)
299-
def test_append_timestamps_aware_or_naive(self, timestamp, timezone):
294+
def test_append_timestamps_aware_or_naive(self, tz_naive_fixture, timestamp):
300295
# GH 30238
301-
df = pd.DataFrame([pd.Timestamp(timestamp, tz=timezone)])
296+
tz = tz_naive_fixture
297+
df = pd.DataFrame([pd.Timestamp(timestamp, tz=tz)])
302298
result = df.append(df.iloc[0]).iloc[-1]
303-
expected = pd.Series(pd.Timestamp(timestamp, tz=timezone), name=0)
299+
expected = pd.Series(pd.Timestamp(timestamp, tz=tz), name=0)
304300
pd.testing.assert_series_equal(result, expected)
305301

306302
def test_update(self):

0 commit comments

Comments
 (0)