-1

I am a beginner in python and need help with the concat() method as the append method has been deprecated. Could anyone show me how to use the concat() method for this code? thanks

def gettrigger(self):
    dfx = pd.DataFrame()
    for i in range(self.lags + 1):
        mask = (self.df['%K'].shift(i) < 20) & (self.df['%D'].shift(i) < 20)
        dfx = dfx.append(mask, ignore_index=True)
    return dfx.sum(axis=0)
  • this question and answers to it might help you! – BytE Jul 06 '22 at 06:17
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 06 '22 at 07:52

1 Answers1

0
dfx = pd.concat([(self.df['%K'].shift(i) < 20) & (self.df['%D'].shift(i) < 20) for i in range(self.lags + 1)],
                ignore_index=True)

The list comprehension will create a list of objects to concatenate.

Ze'ev Ben-Tsvi
  • 1,174
  • 1
  • 3
  • 7