I created a list of locations by doing this:
list_NA = []
for x in df['place']:
if x and x not in list_NA:
list_NA.append(x)
This gives me a list like this:
print(list_NA)
['DEN', 'BOS', 'DAB', 'MIB', 'SAA', 'LAB', 'NYB', 'AGA', 'QRO', 'DCC', 'PBC', 'MIC', 'MDW', 'SAB', 'LAA', 'NYA', 'PHL', 'DCB', 'CHA', 'CHB', 'SEB', 'AGB', 'SEC', 'DAA', 'MEX']
I want to use this list in my where clause like this:
df2 = pd.read_sql("select airport from "+db+" where airport in "+list_NA+"", conn)
But I keep getting this error :
TypeError: Can't convert 'list' object to str implicitly
I tried to do str(list_NA) or tuple(list_NA) but