kemasuda / jaxstar

fast isochrone fitting using HMC-NUTS
MIT License
2 stars 0 forks source link

Pandas DataFrame "append" attribute is deprecated and produces an error #5

Open ahlamaq opened 1 month ago

ahlamaq commented 1 month ago

I have tried running this piece of code from one of the demos:

from jaxstar import mistfit
from jax import random
import arviz, corner
import pandas as pd

mf = mistfit.MistFit()

And I get the following error:

creating grid for mistfit...
/anaconda3/lib/python3.11/site-packages/jaxstar-0.1.0-py3.11.egg/jaxstar/mistfit/mistgrid/create_grid.py:64: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use ``sep='\s+'`` instead
  d = pd.read_csv(filename, delim_whitespace=True, comment='#', header=None, names=header)
Traceback (most recent call last):
  File "jaxstar_ages.py", line 7, in <module>
    mf = mistfit.MistFit()
         ^^^^^^^^^^^^^^^^^
  File "/anaconda3/lib/python3.11/site-packages/jaxstar-0.1.0-py3.11.egg/jaxstar/mistfit/mistfit.py", line 107, in __init__
    path = check_mistgrid_path()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/anaconda3/lib/python3.11/site-packages/jaxstar-0.1.0-py3.11.egg/jaxstar/mistfit/mistfit.py", line 26, in check_mistgrid_path
    create_mistgrid()
  File "/anaconda3/lib/python3.11/site-packages/jaxstar-0.1.0-py3.11.egg/jaxstar/mistfit/mistgrid/create_grid.py", line 71, in create_mistgrid
    df_all = df_all.append(d)
             ^^^^^^^^^^^^^
  File "/anaconda3/lib/python3.11/site-packages/pandas/core/generic.py", line 6299, in __getattr__
    return object.__getattribute__(self, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DataFrame' object has no attribute 'append'. Did you mean: '_append'?

After a quick search, it appears that as of pandas 2.0, append was deprecated and removed. Is it possible to update the package so that it is consistent with more recent pandas versions?

kemasuda commented 1 month ago

Thank you very much for bringing this issue to my attention! I update the main branch (create_mistgrid.py) so that it uses concat function. I hope this works, I'd appreciate it if you could let me know the outcome.

ahlamaq commented 1 month ago

Thank you for the quick response and for updating the script! The code now runs without issue when creating a grid. Just to note, I get the following warning message:

/anaconda3/lib/python3.11/site-packages/jaxstar-0.1.0-py3.11.egg/jaxstar/mistfit/mistgrid/create_grid.py:64: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use ``sep='\s+'`` instead

So, it might be good to also update this to avoid future issues when it is deprecated.

Thank you so much for your help and support.

kemasuda commented 1 month ago

Glad to hear that it worked, and thank you for another note on the deprecated function. I will make sure to update this as well.