Remove first x number of characters from each row in a column of a Python dataframe

前端 未结 2 1653
盖世英雄少女心
盖世英雄少女心 2020-12-24 06:39

I have a Python dataframe with about 1,500 rows and 15 columns. With one specific column I would like to remove the first 3 characters of each row. As a simple example here

2条回答
  •  悲哀的现实
    2020-12-24 06:59

    Use vectorised str methods to slice each string entry

    In [11]:
    d['Report Number'] = d['Report Number'].str[3:]
    d
    
    Out[11]:
         Name Report Number
    0  George       1234567
    1    Bill       9876543
    2   Sally       4434555
    

提交回复
热议问题