I have a dataset called data_set_tweets.csv as below
created_at,tweet,retweet_count
7/29/2021 2:40,Great Sunny day for Cricket at London,3
7/29/2021 10:40,Great Score put on by England batting,0
7/29/2021 11:50,England won the match,1
And what I was trying to do is to get the below output in to a data frame.
Which means I want to iterate the text in the tweet column based on the retweet_count value with same created_at values on that particular tweet
Below is the expected output for my dataset
created_at,tweet
7/29/2021 2:40,Great Sunny day for Cricket at London
7/29/2021 2:40,Great Sunny day for Cricket at London
7/29/2021 2:40,Great Sunny day for Cricket at London
7/29/2021 2:40,Great Sunny day for Cricket at London
7/29/2021 10:40,Great Score put on by England batting
7/29/2021 11:50,England won the match
7/29/2021 11:50,England won the match
Below is how I started my approach
import pandas as pd
def iterateTweets():
tweets = pd.read_csv(r'data_set_tweets.csv')
df = pd.DataFrame(tweets, columns=['created_at', 'tweet', 'retweet_count'])
df['created_at'] = pd.to_datetime(df['created_at'])
df['tweet'] = df['tweet'].apply(lambda x: str(x))
df['retweet_count'] = df['retweet_count'].apply(lambda x: str(x))
# print(df)
return df
if __name__ == '__main__':
print(iterateTweets())
I'm beginner to data frame and python can someone help me out?