Skip to content

Instantly share code, notes, and snippets.

@robotenique
Created May 19, 2019 21:19
Show Gist options
  • Save robotenique/a953e7aa0b119a8296af0a90e6d797b2 to your computer and use it in GitHub Desktop.
Save robotenique/a953e7aa0b119a8296af0a90e6d797b2 to your computer and use it in GitHub Desktop.
np.random.seed(42)
df = (dataset
.rename(columns={"Created At": "publication_date",
"Text": "tweet",
"Retweet Count" : "num_retweets",
"Username": "username",
"Classificacao": "sentiment"})
.loc[:, ["publication_date", "tweet", "num_retweets", "username", "sentiment"]])
df["publication_date"] = pd.to_datetime(df["publication_date"],infer_datetime_format=True)
df["sentiment"] = df["sentiment"].replace({"Negativo": 0, "Neutro": np.random.choice([0, 1]), "Positivo": 1})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment