@@ -911,6 +911,41 @@ def test_pct_change(test_series, freq, periods, fill_method, limit):
911
911
tm .assert_frame_equal (result , expected .to_frame ("vals" ))
912
912
913
913
914
+ @pytest .mark .parametrize (
915
+ "func, expected_status" ,
916
+ [
917
+ ("ffill" , ["shrt" , "shrt" , "lng" , np .nan , "shrt" , "ntrl" , "ntrl" ]),
918
+ ("bfill" , ["shrt" , "lng" , "lng" , "shrt" , "shrt" , "ntrl" , np .nan ]),
919
+ ],
920
+ )
921
+ def test_ffill_bfill_non_unique_multilevel (func , expected_status ):
922
+ # GH 19437
923
+ date = pd .to_datetime (
924
+ [
925
+ "2018-01-01" ,
926
+ "2018-01-01" ,
927
+ "2018-01-01" ,
928
+ "2018-01-01" ,
929
+ "2018-01-02" ,
930
+ "2018-01-01" ,
931
+ "2018-01-02" ,
932
+ ]
933
+ )
934
+ symbol = ["MSFT" , "MSFT" , "MSFT" , "AAPL" , "AAPL" , "TSLA" , "TSLA" ]
935
+ status = ["shrt" , np .nan , "lng" , np .nan , "shrt" , "ntrl" , np .nan ]
936
+
937
+ df = DataFrame ({"date" : date , "symbol" : symbol , "status" : status })
938
+ df = df .set_index (["date" , "symbol" ])
939
+ result = getattr (df .groupby ("symbol" )["status" ], func )()
940
+
941
+ index = MultiIndex .from_tuples (
942
+ tuples = list (zip (* [date , symbol ])), names = ["date" , "symbol" ]
943
+ )
944
+ expected = Series (expected_status , index = index , name = "status" )
945
+
946
+ tm .assert_series_equal (result , expected )
947
+
948
+
914
949
@pytest .mark .parametrize ("func" , [np .any , np .all ])
915
950
def test_any_all_np_func (func ):
916
951
# GH 20653
0 commit comments