I have a dataframe df
that looks like this:
| created_at | favourite_count | hashtags | location | mined_at | name | quote_screen_name | quote_text | retweet_count | retweet_text | screen_name | source_device | status_count | text | tweet_id |
|:----------:|:---------------:|:--------:|:--------:|:--------:|:----:|:-----------------:|:----------:|:-------------:|:--------------------------------------------------:|:-----------:|:-------------------:|:------------:|:-----------------------------------------------------------------------------------------:|:-----------:|
| 49:02.0 | 0 | [] | | 16:07.4 | Eric | None | None | 23 | Sound design in this game is 10/10 game freak lied | narutouz16 | Twitter Web App | 364 | RT @GetMadz: Sound design in this game is 10/10 game freak lied. | 1.19558E+18 |
| 45:43.0 | 1 | [] | | 16:07.4 | Eric | None | None | 0 | None | narutouz16 | Twitter Web App | 364 | @hbthen3rd I know I don't. | 1.19558E+18 |
| 45:25.0 | 0 | [] | | 16:07.4 | Eric | None | None | 0 | None | narutouz16 | Twitter Web App | 364 | @TonyKelly95 I'm still not satisfied in the ending, even though its longer. | 1.19558E+18 |
| 37:42.0 | 0 | [] | | 16:07.4 | Eric | None | None | 0 | None | narutouz16 | Twitter for Android | 364 | I'm currently in second place in my leaderboards in duolongo. | 1.19544E+18 |
| 41:26.0 | 2 | [] | | 16:07.4 | Eric | None | None | 0 | None | narutouz16 | Twitter for Android | 364 | @TheRealRotimi live footage of us at spin. | 1.19515E+18 |
| 40:08.0 | 0 | [] | | 16:07.4 | Eric | None | None | 0 | None | narutouz16 | Twitter for Android | 364 | Duolingo has more content than I thought, add that to another one of my monthly payments. | 1.19515E+18 |
| 05:37.0 | 1 | [] | | 16:07.4 | Eric | None | None | 0 | None | narutouz16 | Twitter for Android | 364 | @TonyKelly95 It dont go down | 1.1951E+18 |
| 29:45.0 | 0 | [] | | 16:07.4 | Eric | None | None | 0 | None | narutouz16 | Twitter Web App | 364 | This is my meme day, where I explore the internet for memes. your welcome. | 1.19482E+18 |
| 18:57.0 | 0 | [] | | 16:07.4 | Eric | None | None | 67134 | Blah | narutouz16 | Twitter Web App | 364 | RT @DitzyFlama: | 1.19482E+18 |
I want to create a new column, is_retweet
, which essentially is based off of the retweet_text
column.
If retweet_text
= 'None'
, then is_retweet = 0 else 1
.
Something like:
df['is_retweet'] = [if 'retweet_text' = 'None' then 0 else 1]
But it yields me:
df['is_retweet'] = [if 'retweet_text' = 'None' then 0 else 1]
^
SyntaxError: invalid syntax
Full code below:
import pandas as pd
df = pd.read_csv("filepath")
df['is_retweet'] = [if 'retweet_text' = 'None' then 0 else 1]