0

I have a json file which has set of values inside brackets. the first number is hour and the second number is production in that hour. I want to use this file in python and plot the data but I don know how to convert the hours to days and sum up the production.

with open('year_2018.json') as f:
    data = json.load(f)
    for i in range(len(data)):
        key = data[i]['key'][0]['en']
        print(key)

    if key == "Wind":
        values = data[i]

        data1 = (values['values'])

        for x, y in data1:

            data_x.append(x)
            data_y.append(y)

[x, y] = [hour, production] here X is the hour (but in weird format like 1545980400000) and y is the production in that hour I expect to plot daily production

  • 1
    Welcome to StackOverFlow Kaven ! Please, have a look at [*How to create a Minimal, Reproducible Example*](https://stackoverflow.com/help/minimal-reproducible-example) and [*How to make good reproducible pandas examples*](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). Then, edit the question providing an input sample and the expected output. – Alexandre B. Aug 03 '19 at 10:23
  • your 'weird format' looks like a unix time stamp in milliseconds, see [here](https://www.epochconverter.com/). Pay attention to the timezone however, the number does not carry this information by itself. You have to infer it from metadata. In any case, you can easily convert it to a python `datetime` object from which you can the retrieve e.g. the hour of day. – FObersteiner Aug 03 '19 at 10:42

0 Answers0