pmorissette / ffn

ffn - a financial function library for Python
pmorissette.github.io/ffn
MIT License
1.96k stars 294 forks source link

Several functions using DataFrame.ix which has been removed from Pandas 1.0.0 #89

Closed neelotpal1112 closed 3 years ago

neelotpal1112 commented 4 years ago

Pandas 1.0.0 has removed the DataFrame.ix indexer. This indexer was being used in several core functions including rebase() and calc_cagr(). In all, there are 11 instances of this indexer being used in the core module. Pandas also seems to have become aggressive in their policy of requiring users to update. It would be good to update the indexer to the suggested .iloc or .loc, as appropriate.

HedgeShot commented 4 years ago

This is linked to the issue #80 that i raised some month ago. If you look at the code on Github, there is no .ix anymore. If you install FFN via pip on windows, you get the latest version without .ix while if you pull it on macOS, you get an older version that breaks with pandas 1.0... @JordanPlatts is there a way you could build the new version for macOS (& probably linux) to fix the small discrepancy?

Thanks a lot. FFN (& BT) don't receive the attention they deserve. They are great tools.

JordanPlatts commented 4 years ago

I am busy with work and can't spend time of bt or ffn. Feel free to fix the issues and I can merge them.

HedgeShot commented 4 years ago

@JordanPlatts There is no issue with FFN itself, so no code to change. The issue is on PIP. Windows version looks fine (no .ix), macOS (& linux) still have an older version of the code (breaks on pandas 1). I have no idea how to fix this.

amoriello commented 4 years ago

Hey folks,

❯ python
Python 3.8.2 (default, Mar 11 2020, 00:29:50)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ffn
>>> ffn.__version__
(0, 3, 4)

But if I look in my python3.8/site-packages/ffn/core.py

      def display_monthly_returns(self):
          """
          Display a table containing monthly returns and ytd returns
          for every year in range.
          """
          data = [['Year', 'Jan', 'Feb', 'Mar', 'Apr', 'May',
                   'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'YTD']]
          for k in self.return_table.index:
              r = self.return_table.ix[k].values.             <<<<<<< uses "ix"
              data.append([k] + [fmtpn(x) for x in r])
          print(tabulate(data, headers='firstrow'))

But in master

I see

    def display_monthly_returns(self):
        """
        Display a table containing monthly returns and ytd returns
        for every year in range.
        """
        data = [['Year', 'Jan', 'Feb', 'Mar', 'Apr', 'May',
                 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'YTD']]
        for k in self.return_table.index:
            r = self.return_table.loc[k].values             <<< uses loc: OK
            data.append([k] + [fmtpn(x) for x in r])
        print(tabulate(data, headers='firstrow'))

This code changed happened in August 4 2018 with this commit

But the Pypi package never got updated: https://pypi.org/project/ffn/#history

@JordanPlatts or @pmorissette or any maintainer, can you guys please bump up the version and upload latest ffn to Pypi?

Thanks a lot!

x829901 commented 4 years ago

PyPL STILL doesn't have the latest version

timkpaine commented 3 years ago

closing, will do a release in the nearish future. Feel free to use an older version of pandas in the mean time.