mwouts / itables

Pandas DataFrames as Interactive DataTables
https://mwouts.github.io/itables/
MIT License
730 stars 54 forks source link

itables causes FutureWarning for using deprecated pandas syntax in pandas 1.5 #107

Closed sjdemartini closed 1 year ago

sjdemartini commented 1 year ago

When using itables with pandas 1.5 for certain types of data in dataframes, it emits a FutureWarning due to using now-deprecated .iloc[] operations (https://pandas.pydata.org/pandas-docs/stable/whatsnew/v1.5.0.html#inplace-operation-when-setting-values-with-loc-and-iloc).

Example reproduction:

import pandas as pd
import itables

df = pd.DataFrame({ 'timestamps': pd.date_range('now', periods=5, freq='S') })
itables.show(df)

results in:

/path/to/site-packages/itables/javascript.py:118: FutureWarning: In a future version, df.iloc[:, i] = newvals will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either df[df.columns[i]] = newvals or, if columns are non-unique, df.isetitem(i, newvals) formatted_df.iloc[:, j] = np.array(fmt.format_array(x.values, None))


Recently discovered this great library and find it super handy right out of the box. Appreciate you releasing it, as well as any improvements!

mwouts commented 1 year ago

Hey @sjdemartini , thanks for reporting this! I will have a look soon.

mwouts commented 1 year ago

This should be fixed in itables==1.3.2. Please give it a try and confirm that everything looks right! Thanks

sjdemartini commented 1 year ago

Awesome, thank you for the super fast turnaround! Confirmed that this is fixed for me (using 1.3.4) 👍

mwouts commented 1 year ago

You're welcome! Thank you also for reporting this.

Also I wanted to mention the 'fix' above did introduce a few regressions (#112 for instance). These regressions were fixed in itables==1.3.5, which by the way has much better support for large tables.