Skip to content

Python Pandas DataFrame output #9

@s-celles

Description

@s-celles

Hello,

It will be nice if get_historic_weather could output Pandas DataFrame:

Here is a very basic code

import pandas as pd

data = ow.get_historic_weather(station_id, start_date, end_date)
df = pd.DataFrame(data)
df['dt'] = pd.to_datetime(df['dt'], unit='s') # convert unix timestamp to datetime
df = df.set_index('dt') # dt is now index of DataFrame

So plotting temperature is now very easy:

import matplotlib.pyplot as plt
df['temp'].map(lambda d: d['ma'] - 273.15).plot()
plt.show()

But that not enough because ideally each column of this dataframe should also be split according dict keys.

Moreover using Pandas Daframe it will be very easy to output CSV or anything else (database table, HDF5, Excel file...)
see http://pandas.pydata.org/pandas-docs/dev/io.html

Kind regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions