Skip to content
Merged
Changes from 1 commit
Commits
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
33 changes: 30 additions & 3 deletions pandas/tests/series/test_combine_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pandas as pd
from pandas import DataFrame, DatetimeIndex, Series, compat, date_range
import pandas.util.testing as tm
from pandas.util.testing import assert_series_equal
from pandas.util.testing import assert_series_equal, assert_frame_equal


class TestSeriesCombine():
Expand Down Expand Up @@ -116,8 +116,35 @@ def test_update(self):
df = DataFrame([{"a": 1}, {"a": 3, "b": 2}])
df['c'] = np.nan

# this will fail as long as series is a sub-class of ndarray
# df['c'].update(Series(['foo'],index=[0])) #####
df['c'].update(Series(['foo'], index=[0]))
expected = DataFrame([[1, np.nan, 'foo'], [3, 2., np.nan]],
columns=['a', 'b', 'c'])
assert_frame_equal(df, expected)

def test_update_dtypes(self):
s = Series([1., 2., False, True])

other = Series([45], index=[0])
s.update(other)

expected = Series([45., 2., False, True])
assert_series_equal(s, expected)

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

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

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

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

def test_concat_empty_series_dtypes_roundtrips(self):

Expand Down