mwouts / itables

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

Broken lengthMenu usage #151

Closed jklap closed 1 year ago

jklap commented 1 year ago
    if "dom" not in kwargs and len(df) <= 10:  # the default page has 10 rows
         if "lengthMenu" not in kwargs or len(df) <= min(kwargs["lengthMenu"]):
             kwargs["dom"] = "t"

The above recent change, specifically min(kwargs["lengthMenu"]) causes a problem if, for example, the following was passed in:

lengthMenu = [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]]

TypeError: '<' not supported between instances of 'str' and 'int'

According to the DataTables documentation lengthMenu can be 1D or 2D array and if 2D then the second array is for display-- hence can be ignored for your min()... therefore:

l = kwargs["lengthMenu"]
min(l if len(l) == 1 else l[0])
mwouts commented 1 year ago

Oh I see... thanks for pointing this out! This is interesting and I will release a fix soon. Do you mind to use version 1.4.3 meanwhile?

jklap commented 1 year ago

Right, had to back down to 1.4.3. Thanks!

mwouts commented 1 year ago

Hey @jklap , I have a PR ready for this. Could you please give it a try with this command?

pip install git+https://github.com/mwouts/itables.git@fix_2d_lengthMenu

Thanks!

jklap commented 1 year ago

@mwouts -- no longer seeing the issue! I verified it was still happening and then upgraded just to be sure!

mwouts commented 1 year ago

Great news! I have just released the new version itables==1.4.5 (now on pip, will soon appear on conda-forge)