In this tutorial we’ll learn how to use Python to get time-series data from the https://openweathermap.org/api and convert it to a https://pandas.pydata.org/docs/index.html. Next we’ll write that data to https://www.influxdata.com/influxcloud-trial/?utm_source=vendor&utm_medium=referral&utm_campaign=2022-07_spnsr-ctn_obtaining-storing-ts-pything_tns, a time-series data platform, with the https://github.com/influxdata/influxdb-client-python. We’ll convert the JSON response from our API call to a Pandas DataFrame because I find that that’s the easiest way to write data to InfluxDB. We’re writing to InfluxDB because it’s a https://www.influxdata.com/time-series-database/?utm_source=vendor&utm_medium=referral&utm_campaign=2022-07_spnsr-ctn_obtaining-storing-ts-pything_tns that’s meant to handle the high ingest requirements and of https://www.influxdata.com/what-is-time-series-data/?utm_source=vendor&utm_medium=referral&utm_campaign=2022-07_spnsr-ctn_obtaining-storing-ts-pything_tns.

# Convert data to Pandas DataFrame and convert timestamp to datetime object df = pd.json_normalize(hourly) df = df.drop(columns=['weather', 'pop']) df['dt'] = pd.to_datetime(df['dt'], unit='s') print(df.head)

Related Articles