I have this code:
latitude = pd.DataFrame()
longitude = pd.DataFrame()
datasets = []
datasets.append(latitude)
datasets.append(longitude)
def fun(key, job):
global latitude
global longitude
if(key == 'LAT'):
latitude = job.copy()
elif(key == 'LON'):
longitude = job.copy()
for d in datasets:
print(d.shape)
Following this: Why does assigning to my global variables not work in Python? I have used the global keyword to ensure that the variables are correctly referenced. However, the values are not updated. Any advice? I have already verified that the if statements are correct as I am able to print something in them.
OUTPUT:
(0, 0)
(0, 0)
Moreover, I am using spyder and I can see that the list contains empty dataframe and also the global variable are empty.