bukosabino / ta

Technical Analysis Library using Pandas and Numpy

Home Page:https://technical-analysis-library-in-python.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting error when working with a dataframe with zeros

Karlheinzniebuhr opened this issue · comments

commented

I'm initializing a dataframe with zeros to then progressively adding data to it. While calling ema_indicator() at each iteration

zeros = np.zeros(1000)
df = pd.DataFrame(zeros)
ema_indicator(df, 1000)

This gives me an exception

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ubuntu/.local/lib/python3.8/site-packages/ta/trend.py", line 1126, in ema_indicator
    return EMAIndicator(close=close, window=window, fillna=fillna).ema_indicator()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/ta/trend.py", line 171, in ema_indicator
    return pd.Series(ema_, name=f"ema_{self._window}")
  File "/home/ubuntu/.local/lib/python3.8/site-packages/pandas/core/series.py", line 367, in __init__
    if is_empty_data(data) and dtype is None:
  File "/home/ubuntu/.local/lib/python3.8/site-packages/pandas/core/construction.py", line 818, in is_empty_data
    is_simple_empty = is_list_like_without_dtype and not data
  File "/home/ubuntu/.local/lib/python3.8/site-packages/pandas/core/generic.py", line 1527, in __nonzero__
    raise ValueError(
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().