0

I want to remove the '00' from the relevant column values in the below dataset.

0         9549917574
1         9600849879
2         9623023075
3         9663914217
4         9672775708

204     965067266400
205     965259283200
206     966127051400
207     963156240300
208     963177760600

I've used the below code:

lc_subs['PARNO'] = lc_subs.PARNO.str.removesuffix('00')

It returns the below error:

'StringMethods' object has no attribute 'removesuffix'

I get the same error for Series if I use the below code:

lc_subs['PARNO'] = lc_subs.PARNO.removesuffix('00')

Thanks!

martineau
  • 119,623
  • 25
  • 170
  • 301
Tickets2Moontown
  • 117
  • 1
  • 10
  • Does this answer your question? [How do I remove a substring from the end of a string in Python?](https://stackoverflow.com/questions/1038824/how-do-i-remove-a-substring-from-the-end-of-a-string-in-python) – Barbaros Özhan Dec 21 '20 at 17:40

1 Answers1

0

You may try this:

a = [9549917574,9600849879,9623023075,9663914217,9672775708,965067266400,965259283200,966127051400,963156240300,963177760600]

b = []

for i in a:
    i = str(i)
    if i.endswith('00'):
        b += [i[:-2]]
    else:
        b += [i]
        

b should return your desired output. You may replace the use of list with a dataframe.

Prateek Jain
  • 231
  • 1
  • 11