How to eliminate empty rows when using Get_Data?

I want to remove rows where Period End Date is null for the past 20 years.

df, err = ek.get_data(['GOOGL.O', 'MSFT.O', 'FB.O', 'AMZN.O', 'TWTR.K'], 
['TR.TotalRevenue.PeriodEndDate', 'TR.TotalRevenue', 'TR.EBITDAActValue', 'TR.EBITActValue'],
{'Scale': 6, 'SDate': -20, 'EDate': 0, 'FRQ': 'FY', 'Curn': 'USD'} )

Best Answer

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭
    Answer ✓

    Use pandas replace and dropna methods.

    import numpy as np
    df['Period End Date'].replace('', np.nan, inplace=True)
    df.dropna(subset=['Period End Date'], inplace=True)
    df