Sai Kumar
Sai Kumar

Reputation: 9

i want to remove integers from a string but not all integers only few integers in a dataframe

I have a dataframe like below:

    Name           Value     Volume
0  2019 sai 20     21321       23
1  2020 James      12311       12
2  2018 Adi 35     4435        11
3  2017 Hello 46   32454       34
4  2019 Girl       654654      56
5  2018 surya 25   325874      89

I want to get a output like this:

    Name       Value     Volume
0   sai 20     21321       23
1   James      12311       12
2   Adi 35     4435        11
3   Hello 46   32454       34
4   Girl       654654      56
5   surya 25   325874      89

Can anyone help me how to do this.

Upvotes: 0

Views: 33

Answers (1)

Ángel Igualada
Ángel Igualada

Reputation: 891

It seems that you want to remove a prefix only. You can do it like this:

import pandas as pd

df = pd.DataFrame([{"Name" : "2019 sai 20", "Value":23, "Volume":23},
                   {"Name" : "2020 James", "Value":23, "Volume":23}])

df["Name"] = df["Name"].str[5:]

Upvotes: 1

Related Questions