-1

i want to delete what after the : in this data (the password) and let just the emails

[emails] https://i.stack.imgur.com/dX9RB.png

anass
  • 13
  • 2
  • 1
    And what's your question about this? – Nico Haase Sep 03 '21 at 06:48
  • Have you tried anything yourself? I mean, we like to fix errors and logic **in code**. While here it seems that you ask to fully program a solution for you... – ZygD Sep 03 '21 at 07:03

1 Answers1

0

You would be looking at apply.

I think a solution like this:

def remove_pw(x): #define your custom function
    y = x.split(":") #simple way to split on the colon
    return y[0] #return only the first part which is the email

df = yourdata

new_df = df['email'].apply(remove_pw)

According to your image: ( I am assuming that what is shown is named df and is a valid pandas dataframe.)

new_df = df['kobastal@yahoo.com:raskolnik'].apply(remove_pw)
Jason Chia
  • 1,144
  • 1
  • 5
  • 18