Giter VIP home page Giter VIP logo

Comments (2)

edesz avatar edesz commented on July 28, 2024

Very strange. This seems to be working fine for me

data = Monthly("65660")
data = data.fetch()
print(data)

            tavg  tmin  tmax  prcp  snow   wdir  wspd  wpgt    pres  tsun
time                                                                     
1942-08-01  23.6   NaN   NaN   NaN   NaN    NaN   NaN   NaN     NaN   NaN
1942-09-01  25.0   NaN   NaN   NaN   NaN    NaN   NaN   NaN     NaN   NaN
1942-10-01  25.4   NaN   NaN   NaN   NaN    NaN   NaN   NaN     NaN   NaN
1942-11-01  26.0  23.0  30.3   NaN   NaN    5.5   5.1   NaN     NaN   NaN
1942-12-01  25.4   NaN   NaN   NaN   NaN    1.2   4.7   NaN  1010.4   NaN
...          ...   ...   ...   ...   ...    ...   ...   ...     ...   ...
2021-03-01  27.1   NaN   NaN   NaN   NaN    NaN   NaN   NaN     NaN   NaN
2021-04-01  27.8   NaN   NaN   NaN   NaN    NaN   NaN   NaN     NaN   NaN
2021-05-01  27.5  24.1  31.7   NaN   NaN    NaN   5.7   NaN  1011.6   NaN
2021-06-01  26.6  23.7  30.5   NaN   NaN  214.9   5.1   NaN  1012.4   NaN
2021-07-01  25.7  23.6  28.7   NaN   NaN    NaN   6.3   NaN  1014.2   NaN

[514 rows x 10 columns]

You may want to check that station['id'] in your code gives the station ID as 65660, which should be a string.

In terms of the overall workflow, where you start with Stations() and then try to get Monthly() data from a single station ID, here is an MRE to show this.

Start by getting a single station (copy-pasted from the documentation example)

from meteostat import Stations, Monthly
stations = Stations()
stations = stations.nearby(49.2497, -123.1193)
station = stations.fetch(1).reset_index()
print(station)

      id                  name country region    wmo  icao  latitude  longitude  elevation           timezone hourly_start hourly_end daily_start  daily_end monthly_start monthly_end     distance
0  71201  Vancouver Harbour CS      CA     BC  71201  CWHC      49.3    -123.12        2.0  America/Vancouver   1980-03-01 2021-08-30  1925-11-01 2021-08-28    1925-01-01  2021-01-01  5593.335349

Note that I had to use .reset_index() in order to access station['id']. I noticed .reset_index() is missing from your code - maybe that is the problem???

Check the monthly_start and monthly_end dates

print(station["monthly_start"][0], station["monthly_end"][0])
1925-01-01 00:00:00 2021-01-01 00:00:00

Both start and end dates are datetimes.

Check the station ID (it should be a string)

print(station['id'][0], type(station['id'][0]))

71201  <class 'str'>

As expected, it is a string.

Finally, use Monthly() with the selected station ID

data = Monthly(station['id'][0])
data = data.fetch()
print(data)

            tavg  tmin  tmax   prcp  snow   wdir  wspd  wpgt    pres  tsun
time                                                                      
1925-11-01   NaN   NaN   NaN   37.6   NaN    NaN   NaN   NaN     NaN   NaN
1925-12-01   NaN   NaN   NaN  349.4   NaN    NaN   NaN   NaN     NaN   NaN
1926-01-01   NaN   NaN   NaN  196.0   NaN    NaN   NaN   NaN     NaN   NaN
1926-02-01   NaN   NaN   NaN  165.5   NaN    NaN   NaN   NaN     NaN   NaN
1926-03-01   NaN   NaN   NaN   64.8   NaN    NaN   NaN   NaN     NaN   NaN
...          ...   ...   ...    ...   ...    ...   ...   ...     ...   ...
2021-02-01   4.5   2.1   6.8  121.1   NaN   82.2  11.5   NaN  1017.7   NaN
2021-03-01   7.5   4.4  10.6   78.3   NaN    NaN   NaN   NaN     NaN   NaN
2021-04-01  10.7   6.8  14.6   47.9   NaN  339.5   9.9   NaN  1019.5   NaN
2021-05-01  13.2   9.4  17.0   59.8   NaN  255.3   9.1   NaN  1019.4   NaN
2021-06-01  18.6  14.0  23.1   39.7   NaN  161.4   8.9   NaN  1014.8   NaN

[938 rows x 10 columns]

Note that if .reset_index() is used when fetching the data, then the station ID value (as a string) can be accessed using station['id'][0]. I suspect you were missing this from your code.

Versions used

import meteostat
print(f"meteostat=={meteostat.__version__}")

meteostat==1.5.10

from meteostat-python.

clampr avatar clampr commented on July 28, 2024

I can confirm what @edesz said 👍

from meteostat-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.