Please I have serious issue with the CSV, Pandas, Dataframe and JSON, I need someone to assist.
`import pandas as pd
import datetime
from pandas_datareader import data, wb
import csv
import json
# declaring libraries for the analysis

out= open("testfile.csv",  "rt") # read the .csv file
data = csv.reader(out)
data = [[row[0],row[1] + "_" + row[2],row[3] +"_" + row[4], row[5],row[6]] for row in data] #this part is mainly to concatenate the City and country
out.close() 

out=open("data.csv", "wt")
output = csv.writer(out)
for row in data:
    output.writerow(row)
out.close()
# <------------ End of concatenation ------------->
# The result is written out and saved in data.csv (I don't want to override the original source)

df = pd.read_csv('data.csv') #using pandas and dataframe, I can read in data and loop it through between the Arrival Date and Departure Date

df.DateDpt = pd.to_datetime(df.DateDpt)
df.DateAr = pd.to_datetime(df.DateAr)
df = df.set_index('DateAr')
new_df = pd.DataFrame()
for i, data in df.iterrows():
    data = data.to_frame().transpose()
    data = data.reindex(pd.date_range(start=data.index[0], end=data.DateDpt[0])).fillna(method='ffill').reset_index().rename(columns={'index': 'DateAr'})
    new_df = pd.concat([new_df, data])

new_df = new_df[['AuthorID', 'ArCity_ArCountry', 'DptCity_DptCountry', 'DateAr', 'DateDpt']]

print (new_df) 
# <---- End of iteration ---->
# Json file : <------ JSON ----------------->

json_dict = {}

for arrival_date, data in new_df.groupby('DateAr'):
    matching_dates = data[data.DateDpt==arrival_date]
    not_matching_dates = data[data.DateDpt!=arrival_date]
    json_dict[arrival_date.strftime('%Y-%m-%d')] = {}
    if not matching_dates.empty:
        for city, flights in matching_dates.groupby('ArCity_ArCountry'):
            json_dict[arrival_date.strftime('%Y-%m-%d')][city] = [str(v) for v in flights.AuthorID.to_dict().values()]
    if not not_matching_dates.empty:
        for city, flights in not_matching_dates.groupby('DptCity_DptCountry'):
            json_dict[arrival_date.strftime('%Y-%m-%d')][city] = [str(v) for v in flights.AuthorID.to_dict().values()]

with open('json_dict.json', 'w') as f:
     json.dump(json_dict, f, indent=4, sort_keys=True)
# <------- End of JSON ---------------->`

CSV File (testfile.csv) 
AuthorID    ArCity  ArCountry   DptCity DptCountry    DateDpt   DateAr
AAA         Paris   France      NewYork UnitedState  2008-03-10 2001-02-02
BBB         Paris   France      NewYork UnitedState  2008-03-10 2001-02-02
CCC         Paris   France      Beijing Japan        2008-03-10 2001-02-02
DDD         Paris   France      NewYork UnitedState  2008-03-10 2001-02-02
EEE         Paris   France      London  UK           2008-03-10 2001-02-02
FFF         Paris   France      NewYork UnitedState  2008-03-10 2001-02-02
GGG         Paris   France      Beijing Japan        2008-03-10 2001-02-02

Expected output: 

```
{
    "2001-02-02": {
        "Beijing _Japan": [
            "CCC",
            "GGG"
        ],
        "London_UK": [
            "EEE"
        ],
        "NewYork_UnitedState": [
            "AAA"
            "BBB"
            "DDD"
            "FFF"
        ],
        "Paris_France": [
            "AAA"
            "BBB"
            "CCC"
            "DDD"
            "EEE"
            "FFF"
        ]

    },

    .
    .
    .
  }

But the current output is 
`{
    "2001-02-02": {
        "Beijing _Japan": [
            "GGG"
        ],
        "London_UK": [
            "EEE"
        ],
        "NewYork_UnitedState": [
            "FFF"
        ]
    },
    "2001-02-03": {
        "Beijing _Japan": [
            "GGG"
        ],
        "London_UK": [
            "EEE"
        ],
        "NewYork_UnitedState": [
            "FFF"
        ]
    },
    .
    .
    .
  }`
``
```
