I'm collecting some data from a website to create a map. I have some strings (latitude and longitude) inside a for loop as follows. Once I get this figured out, I'll be adding other information to the DataFrame.
28.5455
66.91390228
59.01139831542969
44.451599
38.55390167
35.2804985046
34.2961998
39.1754
I'm trying to convert this to a Pandas DataFrame, but when I do that, all the indexes are 0 instead of 0,1,2...
for row in csvread:
icao = row[0]
name = row[1]
latitude = row[2]
longitude = row[3]
metar_link = 'https://www.aviationweather.gov/metar/data?ids=' + icao + '&format=decoded&date=&hours=0'
page = requests.get(metar_link)
soup = bs(page.content, 'html.parser')
if soup.select_one('td:contains("Text:") + td').text == 'No data found' or not 'SM' in (
soup.select_one('td:contains("Text:") + td').text):
#print(icao, 'no metars available for this airport!')
continue
metar = soup.select_one('td:contains("Text:") + td').text
metar_data = func.fraction(metar)
visibility = float(func.convert_to_float(metar_data))
ceiling = func.convert_ceiling(metar)
flight_conditions = func.flight_conditions(ceiling, visibility)
color = func.colorize(flight_conditions)
data = pd.DataFrame({
'lat': [latitude],
'lon': [longitude]
})
print(data)
When I print data, I'm getting:
lat lon
0 28.5455 -81.332901
lat lon
0 66.91390228 -151.529007
lat lon
0 65.99279785 -153.7039948
lat lon
0 59.75439835 -154.9109955
lat lon
0 59.01139831542969 -161.82000732421875
lat lon
0 44.451599 -83.394096
lat lon
0 38.55390167 -121.2979965
lat lon
0 35.2804985046 -116.629997253
lat lon
0 34.2961998 -116.1620026
lat lon
0 39.1754 -76.668297
The problem is all the index are 0, they're supposed to increment by 1. How can I fix this?