1

Anyone familiar with the pandas_ta library? I use the following code to get ichimoku values:

ichi = ta.ichimoku(df['high'], df['low'], df['close'], include_chikou=True)

Ichi type should be data frame but the output is a 2-member tuple. Does anyone know where the problem comes from?

wjandrea
  • 28,235
  • 9
  • 60
  • 81
Yunus1400
  • 11
  • 1

2 Answers2

0

The ichimoku function returns 2 dataframes. The first df with values up until the current candle and one for the forward looking part of the cloud.

Epik
  • 34
  • 2
0

Since a tuple is returned, you can use this code

def add_ichi(self, tenkan: int = 9, kijun: int = 26, senkou: int = 52, offset: int = 26) -> None:
        df_ichi = ta.ichimoku(self.df["high"], self.df["low"], self.df["close"], tenkan=tenkan, kijun=kijun, senkou=senkou, offset=offset)
        df_ichi[0].columns = ["spanA", "spanB", "tenkan_sen", "kijun_sen", "chikou_span"]
        df_ichi[1].columns = ["spanA_future", "spanB_future"]
        self.df["spanA_future"] = df_ichi[1]["spanA_future"]
        self.df["spanB_future"] = df_ichi[1]["spanB_future"]

For example, df_ichi[1]["spanA_future"] - we move the data from tuple [1] to the Pandas dataframe column df["spanA_future"]

Alex
  • 1