Home > Mobile >  How to use pandas concatenate
How to use pandas concatenate

Time:04-21

enter image description here

Hi im running a program and I am being warned that the append method for pandas is being depreciated. How would I use concatenate in the following piece of code.

tweets_df = tweets_df.append(pd.DataFrame({'user_name': tweet.user.name,
                                               'user_location': tweet.user.location,
                                               'user_description': tweet.user.description,
                                               'user_verified': tweet.user.verified,
                                               'date': str(tweet.created_at),
                                               'text': text,
                                               'hashtags': [hashtags if hashtags else None],
                                               'source': tweet.source}))

CodePudding user response:

tweet = pd.Series({
   'user_name': tweet.user.name,
   'user_location': tweet.user.location,
   'user_description': tweet.user.description,
   'user_verified': tweet.user.verified,
   'date': str(tweet.created_at),
   'text': text,
   'hashtags': [hashtags if hashtags else None],
   'source': tweet.source})
df = pd.concat([tweets_df, tweet])
  • Related