@@ -61,7 +61,12 @@ def test_fillna_nat(self):
61
61
tm .assert_frame_equal (filled , expected )
62
62
tm .assert_frame_equal (filled2 , expected )
63
63
64
- def test_fillna (self , datetime_series ):
64
+ def test_fillna_value_or_method (self , datetime_series ):
65
+ msg = "Cannot specify both 'value' and 'method'"
66
+ with pytest .raises (ValueError , match = msg ):
67
+ datetime_series .fillna (value = 0 , method = "ffill" )
68
+
69
+ def test_fillna (self ):
65
70
ts = Series ([0.0 , 1.0 , 2.0 , 3.0 , 4.0 ], index = tm .makeDateIndex (5 ))
66
71
67
72
tm .assert_series_equal (ts , ts .fillna (method = "ffill" ))
@@ -81,10 +86,7 @@ def test_fillna(self, datetime_series):
81
86
with pytest .raises (ValueError , match = msg ):
82
87
ts .fillna ()
83
88
84
- msg = "Cannot specify both 'value' and 'method'"
85
- with pytest .raises (ValueError , match = msg ):
86
- datetime_series .fillna (value = 0 , method = "ffill" )
87
-
89
+ def test_fillna_nonscalar (self ):
88
90
# GH#5703
89
91
s1 = Series ([np .nan ])
90
92
s2 = Series ([1 ])
@@ -108,13 +110,14 @@ def test_fillna(self, datetime_series):
108
110
result = s1 .fillna (Series ({0 : 1 , 1 : 1 }, index = [4 , 5 ]))
109
111
tm .assert_series_equal (result , s1 )
110
112
113
+ def test_fillna_aligns (self ):
111
114
s1 = Series ([0 , 1 , 2 ], list ("abc" ))
112
115
s2 = Series ([0 , np .nan , 2 ], list ("bac" ))
113
116
result = s2 .fillna (s1 )
114
117
expected = Series ([0 , 0 , 2.0 ], list ("bac" ))
115
118
tm .assert_series_equal (result , expected )
116
119
117
- # limit
120
+ def test_fillna_limit ( self ):
118
121
ser = Series (np .nan , index = [0 , 1 , 2 ])
119
122
result = ser .fillna (999 , limit = 1 )
120
123
expected = Series ([999 , np .nan , np .nan ], index = [0 , 1 , 2 ])
@@ -124,6 +127,7 @@ def test_fillna(self, datetime_series):
124
127
expected = Series ([999 , 999 , np .nan ], index = [0 , 1 , 2 ])
125
128
tm .assert_series_equal (result , expected )
126
129
130
+ def test_fillna_dont_cast_strings (self ):
127
131
# GH#9043
128
132
# make sure a string representation of int/float values can be filled
129
133
# correctly without raising errors or being converted
@@ -320,6 +324,7 @@ def test_datetime64_fillna(self):
320
324
)
321
325
tm .assert_series_equal (result , expected )
322
326
327
+ def test_datetime64_fillna_backfill (self ):
323
328
# GH#6587
324
329
# make sure that we are treating as integer when filling
325
330
msg = "containing strings is deprecated"
@@ -774,7 +779,7 @@ def test_fillna_datetime64_with_timezone_tzinfo(self):
774
779
with tm .assert_produces_warning (FutureWarning , match = "mismatched timezone" ):
775
780
result = ser2 .fillna (ts )
776
781
expected = Series ([ser [0 ], ts , ser [2 ]], dtype = object )
777
- # once deprecation is enforced
782
+ # TODO(2.0): once deprecation is enforced
778
783
# expected = Series(
779
784
# [ser2[0], ts.tz_convert(ser2.dtype.tz), ser2[2]],
780
785
# dtype=ser2.dtype,
0 commit comments