Skip to content Skip to sidebar Skip to footer

Error With CORR Function In Pandas

I had a CSV file of 2 stock prices data which I did some native python coding to create 2 single lists of prices (in Decimals) of 2 stock counters. I then converted them to 2 panda

Solution 1:

Ok I realised it works if I parse the list into a pandas series rather than a dataframe & change my initial prices from string to float rather than to decimals. Why doesn't the correlation function work with decimal data types though?

Traceback (most recent call last):
  File "D:/python/NQ_MSFT regression.py", line 64, in <module>
    nqpct = nq_df.pct_change()
  File "C:\Anaconda3\lib\site-packages\pandas\core\generic.py", line 4573, in pct_change
    axis=axis, **kwargs)) - 1)
  File "C:\Anaconda3\lib\site-packages\pandas\core\ops.py", line 866, in flex_wrapper
    return self._binop(other, op, level=level, fill_value=fill_value)
  File "C:\Anaconda3\lib\site-packages\pandas\core\series.py", line 1536, in _binop
    result = func(this_vals, other_vals)
TypeError: unsupported operand type(s) for /: 'decimal.Decimal' and 'float'

Post a Comment for "Error With CORR Function In Pandas"