I can't completely understand your problem as your code is not formatted properly in your question but the error is just an expected datatype error.
You need to convert your dataframe to a np array. Just add .values at the end of your dataframe. So if your input was a sample dataframe like so:
df = pd.DataFrame({"Col1":[1,2,3,4], "Col2":[2,2,3,4]})
Convert the whole thing to a numpy array like so:
sample_array = df.values
or convert one column to a np array like so:
sample_array_2 = df["Col1"].values
Update:
As mentioned in the comments, pandas recommends .to_numpy() instead, so use something like:
sample_array = df.to_numpy()
Answer from Shuvo Saha on Stack OverflowHow to add series to a dataframe with index as dates, but the series is shorter than dataframe.
Can you post the full traceback? It appears that your error isn't occurring in the code you posted as I don't see any argument called tuples.
I do see a possible problem that will be thrown later if the error isn't in the code you posted.
This line of code, is what's in the column Close also a Dataframe or structured data type? It appears you are trying to access df["Closes"][column name] new_df [t] = ema(6,df["Close"][t])
I'm a bit tired so I may have misunderstood what you're doing on this line.
More on reddit.comTypeError: expected np.ndarray (got numpy.ndarray)
python - Argument 'open' has incorrect type (expected numpy.ndarray, got DataFrame) - Stack Overflow
[QST] TypeError: Argument 'real' has incorrect type (expected numpy.ndarray, got ndarray)
I want to add a Series with index as date to a dataframe with an index as dates, but the Series is shorter than the dataframe. The dataframe will have a long list of dates as index and the series will have various starting points in the said dates depending upon the availability of data for that particular stock. My code gives me the following error:
TypeError: Argument 'tuples' has incorrect type (expected numpy.ndarray, got DatetimeArray)
My code is :
new_df = pd.DataFrame(index = df["Close"].index)for t in list(df["Close"].columns):new_df [t] = ema(6,df["Close"][t])return new_df
PS: ema is an exponential moving average function that I created. It gives out the said series with date index.
Can you post the full traceback? It appears that your error isn't occurring in the code you posted as I don't see any argument called tuples.
I do see a possible problem that will be thrown later if the error isn't in the code you posted.
This line of code, is what's in the column Close also a Dataframe or structured data type? It appears you are trying to access df["Closes"][column name] new_df [t] = ema(6,df["Close"][t])
I'm a bit tired so I may have misunderstood what you're doing on this line.
df.merge(df_2, how = 'left')
You can either specify the columns to join on with: left_on=False, right_on=False
or if you don't specify anything, it will join on the index.
Note: This is basically the same thing as a left join in sql.
HTH
This is a known error, you need to uninstall numpy by:
pip uninstall numpy
then install "numpy<1.26.4" afresh.
pip install "numpy<1.26.4"
References:
https://github.com/huggingface/diffusers/issues/9069#issuecomment-2267596351
https://github.com/pytorch/pytorch/issues/135836#issuecomment-2347209235
After a number of trials I figure out why there is problem.
Note that there are two numpy versions numpy (1.26.4) and numpy-base (2.1.2) in the installation. If you uninstall numpy (1.26.4) and then reinstall by conda install numpy==1.26.0, your error will remain; what you need to do is to pip uninstall numpy again to ensure the version 2.1.2 is also removed.