Skip to content

Commit f87f987

Browse files
author
Marco Gorelli
committed
👌 simplify , use fixture in test
1 parent 7b4d39d commit f87f987

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
@@ -6758,7 +6758,6 @@ def append(self, other, ignore_index=False, verify_integrity=False, sort=False):
67586758
)
67596759

67606760
index = Index([other.name], name=self.index.name)
6761-
67626761
idx_diff = other.index.difference(self.columns)
67636762
try:
67646763
combined_columns = self.columns.append(idx_diff)
@@ -6767,8 +6766,8 @@ def append(self, other, ignore_index=False, verify_integrity=False, sort=False):
67676766
other = (
67686767
other.reindex(combined_columns, copy=False)
67696768
.to_frame()
6770-
.T.rename_axis(index.names)
6771-
._convert(datetime=True, timedelta=True)
6769+
.T.infer_objects()
6770+
.rename_axis(index.names)
67726771
)
67736772
if not self.columns.equals(combined_columns):
67746773
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)