vifactor / repostat

Inspired by gitstats project: git repository desktop analyzer
GNU General Public License v3.0
106 stars 13 forks source link

Fix compatibility with pandas 2.0.1 #222

Closed tony2guo closed 1 year ago

tony2guo commented 1 year ago

Since in https://github.com/vifactor/repostat/blob/fc6e974e0010c2d6c9cb91e122e345e0440e18c6/requirements.txt#L4 pandas does not pin to 1.x, Python>=3.8 will have pandas 2.x installed.

In pandas 2.0.1, https://github.com/vifactor/repostat/blob/fc6e974e0010c2d6c9cb91e122e345e0440e18c6/analysis/gitauthors.py#L15 will have TypeError: category type does not support sum operations due to https://github.com/pandas-dev/pandas/issues/46072. This can be fixed by authors_grouped.sum(numeric_only=True).

https://github.com/vifactor/repostat/blob/fc6e974e0010c2d6c9cb91e122e345e0440e18c6/report/htmlreportcreator.py#L79 will have AttributeError: 'DataFrame' object has no attribute 'append' due to https://github.com/pandas-dev/pandas/issues/35407. This can be fixed with concat or loc.

It was tested in Python 3.8 with both pandas 1.3.3 and pandas 2.0.1 and Python 3.11 with pandas 2.0.1. I have also added Python 3.10 and 3.11 to the Ubuntu workflow and edited README.

vifactor commented 1 year ago

Thanks!