My Request.getcall from Python gives me output like below
response.text
'{"results":[{"place":{"type":"coord","value":"44.164:28.641","lat":44.164,"lon":28.641,"tz":"Europe/Bucharest"},"measures":[{"ts":1575331200000,"date":"2019-12-03","temperature_2m":11.78,"temperature_2m_min":11.75,"temperature_2m_max":12.46,"windspeed":3.25,"direction":"SSW","wind_gust":5.43,"relative_humidity_2m":88,"sea_level_pressure":1014,"sky_cover":"cloudy","precipitation":0.0,"snow_depth":0,"thunderstorm":"N","fog":"M"}]},{"place":{"type":"coord","value":"53.546:9.98","lat":53.546,"lon":9.98,"tz":"Europe/Berlin"},"measures":[{"ts":1575331200000,"date":"2019-12-03","temperature_2m":-0.55,"temperature_2m_min":-0.8,"temperature_2m_max":-0.35,"windspeed":3.65,"direction":"WSW","wind_gust":8.62,"relative_humidity_2m":88,"sea_level_pressure":1025,"sky_cover":"mostly_clear","precipitation":0.0,"snow_depth":0,"thunderstorm":"N","fog":"M"}]}]}'
I want to make dataframe df out this
coord date direction fog precipitation relative_humidity_2m sea_level_pressure sky_cover snow_depth temperature_2m temperature_2m_max temperature_2m_min thunderstorm ts wind_gust windspeed
44.164:28.641 3/12/2019 SSW M 0 88 1014 cloudy 0 11.78 12.46 11.75 N 1.57533E+12 5.43 3.25
53.546:9.98 3/12/2019 WSW M 0 88 1025 mostly_clear 0 -0.55 -0.35 -0.8 N 1.57533E+12 8.62 3.65
Also I two scenarios :
response.status==200 the API gives values in response.textthen I want store this dataframe
response.status!=200 the API gives no values response.text then I want populate allother fields as null except the coord
How can this be done?
Normal data gives the following dict:
{'results': [{'place': {'type': 'coord',
'value': '44.164:28.641',
'lat': 44.164,
'lon': 28.641,
'tz': 'Europe/Bucharest'},
'measures': [{'ts': 1575331200000,
'date': '2019-12-03',
'temperature_2m': 11.78,
'temperature_2m_min': 11.75,
'temperature_2m_max': 12.46,
'windspeed': 3.25,
'direction': 'SSW',
'wind_gust': 5.43,
'relative_humidity_2m': 88,
'sea_level_pressure': 1014,
'sky_cover': 'cloudy',
'precipitation': 0.0,
'snow_depth': 0,
'thunderstorm': 'N',
'fog': 'M'}]},
{'place': {'type': 'coord',
'value': '53.546:9.98',
'lat': 53.546,
'lon': 9.98,
'tz': 'Europe/Berlin'},
'measures': [{'ts': 1575331200000,
'date': '2019-12-03',
'temperature_2m': -0.55,
'temperature_2m_min': -0.8,
'temperature_2m_max': -0.35,
'windspeed': 3.65,
'direction': 'WSW',
'wind_gust': 8.62,
'relative_humidity_2m': 88,
'sea_level_pressure': 1025,
'sky_cover': 'mostly_clear',
'precipitation': 0.0,
'snow_depth': 0,
'thunderstorm': 'N',
'fog': 'M'}]}]}