-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame.append with empty DataFrame and Series with tz-aware datetime value allocated object column #35038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
e20cd55
f762000
df2e135
5c9619b
20c3c73
a7ee95f
662f7ef
aa08441
a45517e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1088,19 +1088,14 @@ def test_append_empty_frame_to_series_with_dateutil_tz(self): | |
s = Series({"date": date, "a": 1.0, "b": 2.0}) | ||
df = DataFrame(columns=["c", "d"]) | ||
result = df.append(s, ignore_index=True) | ||
# n.b. it's not clear to me that expected is correct here. | ||
# It's possible that the `date` column should have | ||
# datetime64[ns, tz] dtype for both result and expected. | ||
# that would be more consistent with new columns having | ||
# their own dtype (float for a and b, datetime64ns, tz for date). | ||
expected = DataFrame( | ||
[[np.nan, np.nan, 1.0, 2.0, date]], | ||
columns=["c", "d", "a", "b", "date"], | ||
dtype=object, | ||
) | ||
# These columns get cast to object after append | ||
expected["a"] = expected["a"].astype(float) | ||
expected["b"] = expected["b"].astype(float) | ||
expected["date"] = pd.to_datetime(expected["date"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you just fix expected to do this directly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh, the comment # These columns get cast to object after append now makes more sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add tests for empty EA types (period, interval, categorical), we might already have them but this seems like a good place to put them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as additional values in the Series? a scalar Period and scalar Interval. not sure what to do for categorical. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't work for interval or period. will raise an issue. This was fixed for datetime64[ns, tzutc()] 'by accident', when ensuring consistency between np.concatenate and concat_compat, see #35032 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a different issue for period and interval since concatenating list of Series doesn't work either, whereas for tz-aware datetime works on master. see OP on master
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for period and interval, the issue is not limited to an empty dataframe master
don't think necessary. I think covered by #22994 and #22957 and others linked in those issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kk, yeah sometimes we have scattered tests and hard to tell whether we have exhaustive cases. |
||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonjayhawkins do you remember why is was needed to add this
axis=0
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #35032 (comment)