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 is a dataframe:
import pandas as pd d = { 'Report Number':['8761234567', '8679876543','8994434555'], 'Name' :['George', 'Bill', 'Sally'] } d = pd.DataFrame(d)
I would like to remove the first three characters from each field in the Report Number column of dataframe d.
Report Number
d
Use vectorised str methods to slice each string entry
str
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
1.4m articles
1.4m replys
5 comments
56.9k users