0

From NOAA API, I can get Boston hourly weather forecast information via JSON file. Here is the link: https://api.weather.gov/gridpoints/BOX/70,76 (This JSON file is too long to present comprehensively here, please kindly click the link to see it)

I want to convert some of the weather variables into data frame to proceed further calculation. The expected format is as below for temperature. I will use the same format to get precipitation, snowfall, humidity, etc. expected dataframe format

Now I cannot figure out how to convert it to the dataframe I want. Please kindly help....

For now, here is the best I can do, but still cannot extract validTime and values from Temperature

    import requests
    import pandas as pd
    response = requests.get("https://api.weather.gov/gridpoints/BOX/70,76")
    # create new variable forecast
    forecast=response.json()
    df1 = pd.DataFrame.from_records(forecast['properties']).reset_index() 
    df2=df1.loc[ :1 , ['temperature','quantitativePrecipitation', 'snowfallAmount', 'relativeHumidity',  'windGust', 'windSpeed', 'visibility']]
    df2

current output

  • Please [do not upload images of code or errors when asking a question](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question) - see the answer in the link on why images can hinder others helping you. – MagnusO_O Sep 20 '22 at 21:10
  • Please provide enough code so others can better understand or reproduce the problem. – Community Sep 20 '22 at 21:17

0 Answers0