0

I want to analyse weather data by converting it into a pandas dataframe. They only come as a json.

I have retrieved the JSON file which looks like this (this is only a shortened version):

{
"lat": 52.517,
"lon": 13.3889,
"timezone": "Europe/Berlin",
"timezone_offset": 7200,
"hourly": [
    {
        "dt": 1628002800,
        "temp": 294.78,
        "feels_like": 294.41,
        "pressure": 1011,
        "humidity": 54,
        "dew_point": 285.08,
        "uvi": 1.58,
        "clouds": 20,
        "visibility": 10000,
        "wind_speed": 1.92,
        "wind_deg": 336,
        "wind_gust": 1.73,
        "weather": [
            {
                "id": 801,
                "main": "Clouds",
                "description": "few clouds",
                "icon": "02d"
            }
        ],
        "pop": 0
    }}

Is this the correct way?

Thank you in advance

aerioeus
  • 1,348
  • 1
  • 16
  • 41

1 Answers1

0

This is likely where I would start. Pandas as multiple ways to parse JSON into DataFrames:

pd.json_normalize(df)

Here is another similar question

bkeesey
  • 466
  • 4
  • 12
  • So I would see if something as simple as `pd.json_normalize(data["current"])` or `pd.json_normalize(data)` works for your case. Otherwise I think you might need to add some more detail to your question. There are also multiple parameters for how to deal with the nested values using `max_depth` though it defaults to normalizing all levels. – bkeesey Aug 03 '21 at 17:04