You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: Using variable lookback-lengths in pandas methods
Per underlying stock asset, I utilize a homodyne discriminator derived from close prices which determines the appropriate lookback length for other indicators such as macd, smart volume, ehlers rsi, etc.
When I retrieve history on an asset, the data arrives in bulk. I want to apply my indicators en-masse to the entire dataset instead of having to iterate through each row in order to generate the appropriate values (lookback period, then indicator values). That means ideally I would create the 'lookback period' column on the entire dataset through a homodyne discriminator method/class and subsequently apply all of my indicator classes to the same dataset, most of which may depend on the lookback period.
Given the current implementation of ewm/rolling which seemingly accept only a static integer/float, all of my calculations will be off.
Ideal code which generates the error:
importpandasaspdimportnumpyasnp# Initialize dataframe with source datadf=pd.DataFrame()
df['source'] =pd.Series(range(100, 200))
# Typically 'period' is generated by some class# such as a homodyne discriminator for which# other classes depend on for lookback lengthdf['period'] =np.nandf.period.iloc[0] =1df.period.iloc[-1] =10df.period.interpolate(inplace=True)
df.period=df.period.astype('int64', copy=False)
print(df)
# A given class that depends on the lookback# length determined by the discriminatordf['dependant'] =df.source.ewm(span=df.period, adjust=False).mean()
print(df)
Error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Issue: Using variable lookback-lengths in pandas methods
Per underlying stock asset, I utilize a homodyne discriminator derived from close prices which determines the appropriate lookback length for other indicators such as macd, smart volume, ehlers rsi, etc.
When I retrieve history on an asset, the data arrives in bulk. I want to apply my indicators en-masse to the entire dataset instead of having to iterate through each row in order to generate the appropriate values (lookback period, then indicator values). That means ideally I would create the 'lookback period' column on the entire dataset through a homodyne discriminator method/class and subsequently apply all of my indicator classes to the same dataset, most of which may depend on the lookback period.
Given the current implementation of ewm/rolling which seemingly accept only a static integer/float, all of my calculations will be off.
Ideal code which generates the error:
Error:
INSTALLED VERSIONS
commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-1084-aws
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.23.4
pytest: 4.2.0
pip: 19.0.1
setuptools: 40.8.0
Cython: 0.29.2
numpy: 1.14.5
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: 0.5.1
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: 1.2.16
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
None
The text was updated successfully, but these errors were encountered: