aquacropos / aquacrop

AquaCrop-OSPy: Python implementation of AquaCrop-OS
https://aquacropos.github.io/aquacrop/
Apache License 2.0
102 stars 73 forks source link

the minimum pandas version must be 1.4.0. In earlier versions, an err… #46

Closed pacs27 closed 2 years ago

pacs27 commented 2 years ago

A bug appears when using panda versions earlier than 1.4.0. The error appears when running irrigation method 3 (shedule).

I was following the example number 2. Estimation of irrigation water demands

The error log is:


Traceback (most recent call last):
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/tests/test_irrigation.py", line 37, in test_predefined_schedule_strategy
    model.initialize()
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/aquacrop/core.py", line 150, in initialize
    self.ParamStruct = read_irrigation_management(
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/aquacrop/initialize.py", line 305, in read_irrigation_management
    df = df.reindex(ClockStruct.TimeSpan, fill_value=0).drop("Date", axis=1)
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 324, in wrapper
    return func(*args, **kwargs)
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/frame.py", line 4767, in reindex
    return super().reindex(**kwargs)
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 4809, in reindex
    return self._reindex_axes(
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/frame.py", line 4592, in _reindex_axes
    frame = frame._reindex_index(
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/frame.py", line 4611, in _reindex_index
    return self._reindex_with_indexers(
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 4874, in _reindex_with_indexers
    new_data = new_data.reindex_indexer(
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 673, in reindex_indexer
    new_blocks = [
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 674, in <listcomp>
    blk.take_nd(
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/internals/blocks.py", line 1145, in take_nd
    new_values = algos.take_nd(
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/array_algos/take.py", line 101, in take_nd
    return arr.take(
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/arrays/_mixins.py", line 97, in take
    fill_value = self._validate_scalar(fill_value)
  File "/Users/pacopuig/Desktop/PROGRAMACION/aquacrop/aquacrop/venv/lib/python3.9/site-packages/pandas/core/arrays/datetimelike.py", line 645, in _validate_scalar
    raise TypeError(msg)
TypeError: value should be a 'Timestamp' or 'NaT'. Got 'int' instead.

Maybe this error has to do with the bug 42921 that was fixed in pandas version 1.4.

pacs27 commented 2 years ago

Pathlib is a standard library in python since version 3.4 so it does not have to be installed. It does not make sense to use earlier versions of python as the libraries used are not compatible.

Also, when installing pathlib with virtualenv I get the following error:

Collecting pathlib
  Using cached pathlib-1.0.1.tar.gz (49 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/tmp/pip-install-phjjl5kw/pathlib_08ce30b937cf43a4b5a710a89135a38e/setup.py", 
thomasdkelly commented 2 years ago

Thanks for this looks good