-2

In the image below, bd is the dataframe whose type is pandas.core.frame.DataFrame I'm using Pandas for this. Thanks in advance.

[enter image description here][1]

https://ibb.co/d4BRbk

  • 1
    you forget to upload the image and also show first what you have tried – Kallz Aug 28 '17 at 08:52
  • Sorry about that. Now it's done. – Himanshu Prakash Aug 28 '17 at 09:12
  • 1
    show also what you have tried, and also see how to ask a question 'https://stackoverflow.com/help/how-to-ask' – Kallz Aug 28 '17 at 09:14
  • @HimanshuPrakash Please [embded the image in the question itself](https://meta.stackexchange.com/questions/85516/embed-image-in-stackoverflow). But also include your `DataFrame` + code as **code** (not image). – MSeifert Aug 28 '17 at 09:15
  • Have a look at https://stackoverflow.com/questions/11869910/pandas-filter-rows-of-dataframe-with-operator-chaining – jhoepken Aug 28 '17 at 09:18
  • sorry guys. I'm new to this stackoverflow thing. and about what I've tried for this question, actually I'm not able to figure out how to do it in the first place – Himanshu Prakash Aug 28 '17 at 10:39

1 Answers1

0

You can use re module and replace both year and years with empty string:

df[3] = df[3].apply(lambda x: re.sub('\syear(s?)', '', x))
zipa
  • 27,316
  • 6
  • 40
  • 58