This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yearlist = np.sort(data['year'].unique()) | |
imageio.mimsave('./yearmap.gif', [plot_map_gif(y) for y in yearlist], fps=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_map_gif(year): | |
filterdata = data[data.year == year] | |
df = pd.DataFrame() | |
df['lat'] = pd.to_numeric(filterdata['latitude'], errors='coerce') | |
df['long'] = pd.to_numeric(filterdata['longitude '], errors='coerce') | |
df = df.dropna() | |
fig = plt.figure(figsize=(20,10)) | |
plt.rcParams.update({'font.size': 20}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig.canvas.draw() | |
image = np.frombuffer(fig.canvas.tostring_rgb(), dtype='uint8') | |
image = image.reshape(fig.canvas.get_width_height()[::-1] + (3,)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_map_gif(year): | |
filterdata = data[data.year == year] | |
df = pd.DataFrame() | |
df['lat'] = pd.to_numeric(filterdata['latitude'], errors='coerce') | |
df['long'] = pd.to_numeric(filterdata['longitude '], errors='coerce') | |
df = df.dropna() | |
fig = plt.figure(figsize=(20,10)) | |
plt.rcParams.update({'font.size': 20}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_map_gif(year): | |
filterdata = data[data.year == year] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_map_gif(year): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import imageio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Separate Latitude and Longitude, Re-format, Clean | |
df = pd.DataFrame() | |
df['lat'] = pd.to_numeric(filterdata['latitude'], errors='coerce') # Change to filterdata here | |
df['long'] = pd.to_numeric(filterdata['longitude '], errors='coerce') # Change to filterdata here | |
df = df.dropna() | |
# Set Figure and Font Sizes | |
fig = plt.figure(figsize=(20,10)) | |
plt.rcParams.update({'font.size': 20}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filterdata = data[data.year >= 2010] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data['date posted'] = pd.to_datetime(data['date posted']) | |
data['year'] = pd.DatetimeIndex(data['date posted']).year |