-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
regression fix for merging DF with datetime index with empty DF #36897
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
Merged
jreback
merged 17 commits into
pandas-dev:master
from
PCerles:phil/possible-merge-bugfix
Nov 3, 2020
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
16a7844
possible fix for missing datetime data types
PCerles 029447d
update comment
PCerles 30d0c90
added test
PCerles 08d0ef1
updated test
PCerles 3da79a4
added release note
PCerles b3a5261
restructured test to not rely on reset_index
PCerles d85af30
and make data smaller
PCerles 70651d1
reformat from pd.NA
PCerles a70c0ff
test fixes
PCerles ce3a1fa
structure
PCerles 83be75e
comma missing
PCerles fe1335e
fix import and explicitly construct multi indexes
PCerles e5045f3
changed 1.2 release notes and added right/left tests
PCerles 9fb0687
accidentally removed newline
PCerles 0f856dd
fix auto formatter
PCerles b1c7519
changed doc place and parametrized test
PCerles 84822c6
restructured test per pr comments
PCerles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
reformat from pd.NA
- Loading branch information
commit 70651d1b9913657b4d5c9a2764b249f106ce10c5
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -458,23 +458,26 @@ def test_merge_na_keys(self): | |
tm.assert_frame_equal(result, expected) | ||
|
||
def test_merge_datetime_index_empty_df(self): | ||
data = [ | ||
[pd.Timestamp("1950-01-01"), "A", 1.5], | ||
[pd.Timestamp("1950-01-02"), "B", 1.5], | ||
] | ||
|
||
frame = DataFrame(data, columns=["date", "panel", "data"]).set_index( | ||
date = np.array( | ||
[pd.Timestamp("1950-01-01"), pd.Timestamp("1950-01-02")], | ||
PCerles marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dtype=np.datetime64, | ||
) | ||
panel = np.array(["A", "B"], dtype=object) | ||
data = np.array([1.5, 1.5], dtype=np.float64) | ||
|
||
frame = DataFrame({"date": date, "panel": panel, "data": data}).set_index( | ||
B22F ["date", "panel"] | ||
) | ||
other = DataFrame(columns=["date", "panel", "state"]).set_index( | ||
["date", "panel"] | ||
) | ||
expected_data = [ | ||
[pd.Timestamp("1950-01-01"), "A", 1.5, pd.NA], | ||
[pd.Timestamp("1950-01-02"), "B", 1.5, pd.NA], | ||
] | ||
|
||
expected = DataFrame(expected_data, columns=["date", "panel", "data", "state"]) | ||
state = np.array([np.nan, np.nan], dtype=object) | ||
|
||
expected = DataFrame( | ||
PCerles marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{"date": date, "panel": panel, "data": data, "state": state} | ||
) | ||
expected = expected.set_index(["date", "panel"]) | ||
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 write these tests without using set_index or reset_index (building data explicitly using constructors)? Helps isolate the testing to only merge and make things easier to understand. Also could make the original data smaller. |
||
|
||
result = frame.merge(other, how="left", on=["date", "panel"]) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.