For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
26 3 2 6

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'} )
eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
39.2k 75 11 27

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
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea