Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

data loading

Let’s load a dataset on rain precipitations on Seattle on 2014

Let’s visualize

[assignement]: plot the amount of rain (in mm) over time; make sure you put a proper label on both axes, and on the global figure

Let’s answer the following questions

What is the shape and dype of the ndarray?

How many rainy days?

Average precipitation on the year?

Average precipitation on the rainy days?

Mean precipitation on January?

Mean precipitation on January on the rainy days?

A transition to pandas

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File pandas/_libs/tslibs/offsets.pyx:6338, in pandas._libs.tslibs.offsets.to_offset()
-> 6338 'Could not get source, probably due dynamically evaluated source code.'

File pandas/_libs/tslibs/offsets.pyx:6205, in pandas._libs.tslibs.offsets._validate_to_offset_alias()
-> 6205 'Could not get source, probably due dynamically evaluated source code.'

ValueError: 'm' is no longer supported for offsets. Please use 'ME' instead.

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
Cell In[10], line 10
      6 s.index = pd.to_datetime(s.index, unit='D',
      7                          origin=pd.Timestamp('1/1/2004'))
      8 
      9 # possibly resample per month to get the total monthly rain
---> 10 s = s.resample('m').max()

File /__w/exos-ds/exos-ds/venv/lib/python3.14/site-packages/pandas/core/generic.py:9411, in NDFrame.resample(self, rule, closed, label, convention, on, level, origin, offset, group_keys)
   9407         Freq: 17min, dtype: int64
   9408         """
   9409         from pandas.core.resample import get_resampler
   9410 
-> 9411         return get_resampler(
   9412             cast("Series | DataFrame", self),
   9413             freq=rule,
   9414             label=label,

File /__w/exos-ds/exos-ds/venv/lib/python3.14/site-packages/pandas/core/resample.py:2334, in get_resampler(obj, **kwds)
   2330 def get_resampler(obj: Series | DataFrame, **kwds) -> Resampler:
   2331     """
   2332     Create a TimeGrouper and return our resampler.
   2333     """
-> 2334     tg = TimeGrouper(obj, **kwds)  # type: ignore[arg-type]
   2335     return tg._get_resampler(obj)

File /__w/exos-ds/exos-ds/venv/lib/python3.14/site-packages/pandas/core/resample.py:2420, in TimeGrouper.__init__(self, obj, freq, key, closed, label, how, fill_method, limit, convention, origin, offset, group_keys, **kwargs)
   2418     freq = to_offset(freq, is_period=True)
   2419 else:
-> 2420     freq = to_offset(freq)
   2422 if not isinstance(freq, Tick):
   2423     if offset is not None:

File pandas/_libs/tslibs/offsets.pyx:6254, in pandas._libs.tslibs.offsets.to_offset()
-> 6254 'Could not get source, probably due dynamically evaluated source code.'

File pandas/_libs/tslibs/offsets.pyx:6377, in pandas._libs.tslibs.offsets.to_offset()
-> 6377 'Could not get source, probably due dynamically evaluated source code.'

File pandas/_libs/tslibs/offsets.pyx:6162, in pandas._libs.tslibs.offsets.raise_invalid_freq()
-> 6162 'Could not get source, probably due dynamically evaluated source code.'

ValueError: Invalid frequency: m. Failed to parse with error message: ValueError("'m' is no longer supported for offsets. Please use 'ME' instead.")