Closed maaaaz closed 1 year ago
Is this something you were able to do before with LooseVersion or LegacyVersion?
Ah, can you just try key=np.vectorize(LooseVersion)
?
Confirmed:
In [1]: import looseversion as lv
In [2]: import pandas as pd
In [3]: import numpy as np
In [4]: df = pd.DataFrame({"version": ['3.00.12-beta', '02.0.1', '1.0b'] })
In [5]: df.sort_values(by='version', key=np.vectorize(lv.LooseVersion))
Out[5]:
version
2 1.0b
1 02.0.1
0 3.00.12-beta
Thanks, it seems to work
>>> df = pd.DataFrame({"version": ['3.00.12-beta', '02.0.1', '1.0b'] })
>>> df.sort_values(by='version', key=np.vectorize(LooseVersion))
version
2 1.0b
1 02.0.1
0 3.00.12-beta
But I have to admit that needing the not-small "numpy" package is a major drawback: any plan to support without the need of numpy ?
Numpy is a pandas dependency. If you're using pandas, numpy is already imported.
Ok!
Hello,
First, let me thank you for providing this package after all the depreciation and broken things by
distutils
andpackaging.version
. Then, I am currently facing an issue usinglooseversion
in a panda context:While it perfectly works in a non-panda context:
Cheers!