Reputation: 502
I have the following code below which works quite well for what I want to do: However, it takes 40 minutes to complete for 64000 rows. The sricpt creates a new column called PN 3D which takes only the first 3 numbers from the column "Part No.
for pn in ro['Part No.']:
ro['PN 3D'] = ro['Part No.'].apply(lambda pn: str(pn)[:3])
There is any other way to speed up my program? Thank in advance
Upvotes: 2
Views: 111
Reputation: 2821
You don't need the loop:
ro['PN 3D'] = ro['Part No.'].apply(lambda pn: str(pn)[:3])
Upvotes: 5