File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
pandas/tests/series/indexing Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -928,3 +928,24 @@ def test_uint_drop(any_int_dtype):
928928 series .loc [0 ] = 4
929929 expected = pd .Series ([4 , 2 , 3 ], dtype = any_int_dtype )
930930 tm .assert_series_equal (series , expected )
931+
932+ def test_head_tail (test_data ):
933+ assert_series_equal (test_data .series .head (), test_data .series [:5 ])
934+ assert_series_equal (test_data .series .head (0 ), test_data .series [0 :0 ])
935+ assert_series_equal (test_data .series .tail (), test_data .series [- 5 :])
936+ assert_series_equal (test_data .series .tail (0 ), test_data .series [0 :0 ])
937+
938+
939+ def test_index_map ():
940+ # see GH20990
941+ count = 6
942+ index = pd .date_range ("2018-01-01" , periods = count , freq = "M" )
943+
944+ a = Series (np .arange (count ), index = index )
945+ a .index .name = "name"
946+
947+ b = a .copy ()
948+ try :
949+ b .index = a .index .map (lambda x : (x .year , x .month ))
950+ except ValueError :
951+ pytest .fail ("Unexpected ValueError" )
You can’t perform that action at this time.
0 commit comments