<jupyter_start><jupyter_text>The following code are to plot the line graph in Indonesia Case Study section.  Data pre-processing<jupyter_code>import pandas as pd
import scipy
from scipy import stats
import os
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pylab import datestr2num
# Merge monthly Facebook movement data
folder_path = 'E:\GRADUATE STUDY\GE5219\Data\Movement\Results\Monthly\Monthly'
movement = []
for filename in os.listdir(folder_path):
    df = pd.read_csv(folder_path + "\\" + filename, header = 0)
    movement.append(df)
movement = pd.concat(movement)
movement.to_csv("all.csv", header=0, index=0)

print(movement)
# Merge monthly NO2 data
folder_path = r"E:\GRADUATE STUDY\GE5219\Data\NO2_raw_daily"
NO2 = []
name = []
for filename in os.listdir(folder_path):
    df = pd.read_csv(folder_path + "\\" + filename, header = 0)
    name = filename
    df['date']=name[4:14]
    NO2.append(df)
NO2 = pd.concat(NO2)
NO2
filepath = r"E:\GRADUATE STUDY\GE5219\Data\NO2_raw_monthly\monthlyNO2ID.csv"
NO2 = pd.read_csv(filepath)
NO2['NO2'] = pd.to_numeric(NO2['NO2']) 
group_NO2 = NO2.groupby('month')['NO2'].sum()
group_NO2 = group_NO2.reset_index()
group_NO2['month'] = pd.to_datetime(group_NO2['month'],format='%y-%b')
group_NO2 = group_NO2.sort_values(by=['month'],ascending=True)
group_NO2['month'] = pd.to_datetime(group_NO2['month'],format='%b-%y')
filepath = r"E:\GRADUATE STUDY\GE5219\Data\Movement\Results\Monthly\Monthly\all.csv"
Movement = pd.read_csv(filepath)
Movement
filepath = r"E:\GRADUATE STUDY\GE5219\Data\Movement\Results\Monthly\Monthly\all.csv"
Movement = pd.read_csv(filepath)
group_Movement = Movement.groupby('date')['Facebook Movement'].sum()
group_Movement = group_Movement.reset_index()
group_Movement['date'] = pd.to_datetime(group_Movement['date'],format='%Y/%m')
group_Movement = group_Movement.sort_values(by=['date'],ascending=True)
group_Movement['date'] = pd.to_datetime(group_Movement['date'],format='%Y/%m')
group_Movement = group_Movement.sort_values(by=['date'],ascending=True)<jupyter_output><empty_output><jupyter_text>Plot<jupyter_code>fig, ax = plt.subplots(figsize=(5, 2.7), layout='constrained')
dates = np.arange(np.datetime64('2021-11-15'), np.datetime64('2021-12-25'),
                  np.timedelta64(1, 'h'))
data = np.cumsum(np.random.randn(len(dates)))
ax.plot(dates, data)
cdf = mpl.dates.ConciseDateFormatter(ax.xaxis.get_major_locator())
ax.xaxis.set_major_formatter(cdf);
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
fig.set_figheight(5)
fig.set_figwidth(18)
x1 = group_NO2['month']
x2 = group_Movement['date']

ax2.plot(x1, group_NO2['NO2'], label='NO2',color='orange')
ax1.plot(x2, group_Movement['Facebook Movement'], color='blue', label='Facebook Movement')

ax1.set_ylim((0,48000000))
ax2.set_ylim((0,0.058))
ax2.set(ylabel='NO2', xlabel='Time', title='Comparison of NO2 and Movement during COVID-19')
ax1.set(ylabel='Facebook Movement')
fig.legend(loc=1, bbox_to_anchor=(2.95,1.1), bbox_transform=ax.transAxes)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16354679802955666, 'fraction_numerical': 0.04039408866995074, 'mean_word_length': 6.81025641025641, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '30660', 'license': 'MIT', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1189, 'n_words': 183, 'path': 'code/Line_graph.ipynb', 'repo_name': 'liyangyang515/Spatio-Temporal-Patterns-of-NO2-and-Mobility-Through-the-Variants-of-COVID-19-in-SEA', 'size': '3045'}