Skip to content

Instantly share code, notes, and snippets.

@jonathanmc
Last active March 23, 2022 01:22
Show Gist options
  • Save jonathanmc/aa5e0f5236c1ee4faaac9cf79472272b to your computer and use it in GitHub Desktop.
Save jonathanmc/aa5e0f5236c1ee4faaac9cf79472272b to your computer and use it in GitHub Desktop.
TWINT
# Once you have pulled a JSON of tweets with TWINT, you can use this to plot per day.
# You need to feed it the file_to_open variable.
file_to_open = "FILENAME WITHOUT EXTENSION"
import nest_asyncio
from pandas.core.frame import DataFrame
# pandas to read our JSON/CSV file
import pandas as pd
# load file into dataframe df
dforig = pd.read_json(file_to_open + '.json', lines = True)
df = dforig
df.dropna(inplace = True) # drop null values to avoid errors
# graph posts per day
import matplotlib.pyplot as plt
df = dforig
df['date'].value_counts().plot()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment