/usr/local/lib64/python3.6/site-packages/pandas/tests/frame/methods
NameSizeModeActions
__pycache__/-0755rm
test_align.py103390644editdlrm
test_append.py73990644editdlrm
test_asfreq.py19700644editdlrm
test_asof.py57670644editdlrm
test_assign.py29820644editdlrm
test_astype.py210270644editdlrm
test_at_time.py32050644editdlrm
test_between_time.py36750644editdlrm
test_clip.py60280644editdlrm
test_combine.py13590644editdlrm
test_combine_first.py127480644editdlrm
test_compare.py61580644editdlrm
test_count.py10680644editdlrm
test_cov_corr.py118880644editdlrm
test_describe.py124920644editdlrm
test_diff.py73740644editdlrm
test_drop.py156620644editdlrm
test_droplevel.py8550644editdlrm
test_drop_duplicates.py133870644editdlrm
test_duplicated.py31910644editdlrm
test_explode.py52940644editdlrm
test_filter.py49330644editdlrm
test_first_and_last.py18030644editdlrm
test_head_tail.py11940644editdlrm
test_interpolate.py118160644editdlrm
test_isin.py73240644editdlrm
test_nlargest.py67310644editdlrm
test_pct_change.py34360644editdlrm
test_pop.py12260644editdlrm
test_quantile.py180280644editdlrm
test_rank.py113770644editdlrm
test_reindex_like.py11870644editdlrm
test_rename.py125430644editdlrm
test_rename_axis.py40740644editdlrm
test_replace.py592300644editdlrm
test_reset_index.py125060644editdlrm
test_round.py79160644editdlrm
test_select_dtypes.py121040644editdlrm
test_set_index.py195710644editdlrm
test_shift.py103240644editdlrm
test_sort_index.py256780644editdlrm
test_sort_values.py253580644editdlrm
test_to_dict.py99890644editdlrm
test_to_period.py9840644editdlrm
test_to_records.py139810644editdlrm
test_to_timestamp.py40200644editdlrm
test_transpose.py24260644editdlrm
test_truncate.py41800644editdlrm
test_tz_convert.py34150644editdlrm
test_tz_localize.py6660644editdlrm
test_update.py42590644editdlrm
test_value_counts.py26310644editdlrm
__init__.py2290644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/pandas/tests/frame/methods/test_update.py (4259B)
import numpy as np import pytest import pandas as pd from pandas import DataFrame, Series, date_range import pandas._testing as tm class TestDataFrameUpdate: def test_update_nan(self): # #15593 #15617 # test 1 df1 = DataFrame({"A": [1.0, 2, 3], "B": date_range("2000", periods=3)}) df2 = DataFrame({"A": [None, 2, 3]}) expected = df1.copy() df1.update(df2, overwrite=False) tm.assert_frame_equal(df1, expected) # test 2 df1 = DataFrame({"A": [1.0, None, 3], "B": date_range("2000", periods=3)}) df2 = DataFrame({"A": [None, 2, 3]}) expected = DataFrame({"A": [1.0, 2, 3], "B": date_range("2000", periods=3)}) df1.update(df2, overwrite=False) tm.assert_frame_equal(df1, expected) def test_update(self): df = DataFrame( [[1.5, np.nan, 3.0], [1.5, np.nan, 3.0], [1.5, np.nan, 3], [1.5, np.nan, 3]] ) other = DataFrame([[3.6, 2.0, np.nan], [np.nan, np.nan, 7]], index=[1, 3]) df.update(other) expected = DataFrame( [[1.5, np.nan, 3], [3.6, 2, 3], [1.5, np.nan, 3], [1.5, np.nan, 7.0]] ) tm.assert_frame_equal(df, expected) def test_update_dtypes(self): # gh 3016 df = DataFrame( [[1.0, 2.0, False, True], [4.0, 5.0, True, False]], columns=["A", "B", "bool1", "bool2"], ) other = DataFrame([[45, 45]], index=[0], columns=["A", "B"]) df.update(other) expected = DataFrame( [[45.0, 45.0, False, True], [4.0, 5.0, True, False]], columns=["A", "B", "bool1", "bool2"], ) tm.assert_frame_equal(df, expected) def test_update_nooverwrite(self): df = DataFrame( [[1.5, np.nan, 3.0], [1.5, np.nan, 3.0], [1.5, np.nan, 3], [1.5, np.nan, 3]] ) other = DataFrame([[3.6, 2.0, np.nan], [np.nan, np.nan, 7]], index=[1, 3]) df.update(other, overwrite=False) expected = DataFrame( [[1.5, np.nan, 3], [1.5, 2, 3], [1.5, np.nan, 3], [1.5, np.nan, 3.0]] ) tm.assert_frame_equal(df, expected) def test_update_filtered(self): df = DataFrame( [[1.5, np.nan, 3.0], [1.5, np.nan, 3.0], [1.5, np.nan, 3], [1.5, np.nan, 3]] ) other = DataFrame([[3.6, 2.0, np.nan], [np.nan, np.nan, 7]], index=[1, 3]) df.update(other, filter_func=lambda x: x > 2) expected = DataFrame( [[1.5, np.nan, 3], [1.5, np.nan, 3], [1.5, np.nan, 3], [1.5, np.nan, 7.0]] ) tm.assert_frame_equal(df, expected) @pytest.mark.parametrize( "bad_kwarg, exception, msg", [ # errors must be 'ignore' or 'raise' ({"errors": "something"}, ValueError, "The parameter errors must.*"), ({"join": "inner"}, NotImplementedError, "Only left join is supported"), ], ) def test_update_raise_bad_parameter(self, bad_kwarg, exception, msg): df = DataFrame([[1.5, 1, 3.0]]) with pytest.raises(exception, match=msg): df.update(df, **bad_kwarg) def test_update_raise_on_overlap(self): df = DataFrame( [[1.5, 1, 3.0], [1.5, np.nan, 3.0], [1.5, np.nan, 3], [1.5, np.nan, 3]] ) other = DataFrame([[2.0, np.nan], [np.nan, 7]], index=[1, 3], columns=[1, 2]) with pytest.raises(ValueError, match="Data overlaps"): df.update(other, errors="raise") def test_update_from_non_df(self): d = {"a": Series([1, 2, 3, 4]), "b": Series([5, 6, 7, 8])} df = DataFrame(d) d["a"] = Series([5, 6, 7, 8]) df.update(d) expected = DataFrame(d) tm.assert_frame_equal(df, expected) d = {"a": [1, 2, 3, 4], "b": [5, 6, 7, 8]} df = DataFrame(d) d["a"] = [5, 6, 7, 8] df.update(d) expected = DataFrame(d) tm.assert_frame_equal(df, expected) def test_update_datetime_tz(self): # GH 25807 result = DataFrame([pd.Timestamp("2019", tz="UTC")]) result.update(result) expected = DataFrame([pd.Timestamp("2019", tz="UTC")]) tm.assert_frame_equal(result, expected)