When I try to linregress
the Date
and Close
field from a dataframe
I keep getting the error
.
Traceback (most recent call last): File "", line 1, in File "C:\Python34\lib\site-packages\scipy\stats_stats_mstats_common.py", >line 75, in linregress xmean = np.mean(x, None) File "C:\Python34\lib\site-packages\numpy\core\fromnumeric.py", line 2942, in >mean out=out, **kwargs) File "C:\Python34\lib\site-packages\numpy\core_methods.py", line 65, in >_mean ret = umr_sum(arr, axis, dtype, out, keepdims) TypeError: ufunc add cannot use operands with types dtype('dtype('
The code I am using.
import openpyxl,os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import datetime
import pandas_datareader as pdr
from scipy.stats import linregress
start = datetime.datetime(2010,1,1)
end = datetime.datetime(2017,11,10)
i = NSE/CHENNPETRO
df = pdr.DataReader(i, 'quandl', start, end)
# df = df.iloc[::-1]
linregress(df.index,df['Close'])
If someone could help me out or point me where to look I would be most greatful.
TIA