8000 TST: add tests for keeping dtype in Series.update by h-vetinari · Pull Request #23604 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TST: add tests for keeping dtype in Series.update #23604

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
merged 19 commits into from
Nov 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review (jreback)
  • Loading branch information
h-vetinari committed Nov 12, 2018
commit c180b48d1bd0db58f128be102bcdfc656e8f4d71
20 changes: 10 additions & 10 deletions pandas/tests/series/test_combine_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,24 @@ def test_update_dtypes(self):
expected = Series([45., 2., False, True])
assert_series_equal(s, expected)

t_src = Series([10, 11, 12])
t = t_src.copy()
s = Series([10, 11, 12])
s_copy = s.copy()
other = Series([61, 63], index=[1, 3])
t.update(other)
s_copy.update(other)

expected = Series([10, 61, 12])
assert_series_equal(t, expected)
assert_series_equal(s_copy, expected)

# we always try to keep original dtype, even if other has different one
t = t_src.copy()
t.update(other.astype(float))
assert_series_equal(t, expected)
s_copy = s.copy()
s_copy.update(other.astype(float))
assert_series_equal(s_copy, expected)

# if keeping the dtype is not possible, we allow upcasting
t = t_src.copy()
t.update(other + 0.1)
s_copy = s.copy()
s_copy.update(other + 0.1)
expected = Series([10., 61.1, 12.])
assert_series_equal(t, expected)
assert_series_equal(s_copy, expected)

def test_concat_empty_series_dtypes_roundtrips(self):

Expand Down
0