Python- If, and, and or - across rows and columns

Viewed 50
  1. I am new to Pandas and am trying to recreate some excel sheets I have created as an introduction to pandas.
  2. In excel I have the formula: =IF(J99="","",IF(OR(AND(I98>J98,I99<J99),AND(I98<J98,I99>J99)),E99,""))
  3. I have currently created a MACD dataframe using:
    import pandas_ta as ta
    import yfinance as yf
    
    #Inputs
    
    ticker= "AAPL"
    time = '5y'
    Lower_MA= 12
    Upper_MA= 26
    Span = 9
    df2= yf.Ticker(ticker).history(period= time)[['Close','Open','Volume']]
    df2.ta.macd(close='Close', fast= Lower_MA,slow= Upper_MA, signal= Span, append=True)
  1. I now want to do something similar to the excel formula where column I= MACDs, J=MACDh, and E is the date. Is this possible, or am I biting off more than I can chew too early.
0 Answers
Related