0

I am having a pandas data frame like below:-

    Tweets
0   RT @cizzorz: THE CHILLER TRAP *TEMPLE RUN* OBS...
1   Disco Domination receives a change in order to...
2   It's time for the Week 3 #FallSkirmish Trials!...
3   Dance your way to victory in the new Disco Dom...
4   Patch v6.02 is available now with a return fro...
5   Downtime for patch v6.02 has begun. Find out a...
6   ⛏️... soon
7   Launch into patch v6.02 Wednesday, October 10!...
8   Righteous Fury.\n\nThe Wukong and Dark Vanguar...
9   RT @wbgames: WB Games is happy to bring @Fortn...

I want to exclude all the tweets which are having @username in it, maybe i can say if the tweet is having an @ sign i want it to exclude from the df. So, I want to ignore the below lines and get them into a separate df and delete them from the original ones.

 0  RT @cizzorz: THE CHILLER TRAP *TEMPLE RUN* OBS...
 9  RT @wbgames: WB Games is happy to bring @Fortn...

and rest of the tweets will be in the same df.

P.S. - I just want to perform it for @ sign and for no other special character.

1 Answers1

1

This is simply filtering, you can do this with a conditional I believe.

Try this:

df[~df["Tweets"].str.contains("@")]

the ~ acts like a boolean operator, and then you check whether the substring @ is inside each Tweets cell.

Alexis Drakopoulos
  • 1,065
  • 3
  • 16