How to parse Google Ads batch stream into pandas dataframe?

I am having trouble parsing batch response from my Google Ads request. I am able to get the response as json that looks like this:

    results {
  metrics {
    clicks: 200
    conversions_value: 5
    conversions: 40
    cost_micros: 4546564
    impressions: 1235
  }
  segments {
    date: "2021-08-03"
  }
  landing_page_view {
    resource_name: "first"
    unexpanded_final_url: "https://www.soomething.com/find"
  }
}
results {
  metrics {
    clicks: 1000
    conversions_value: 10
    conversions: 65
    cost_micros: 654654
    impressions: 8154
  }
  segments {
    date: "2021-08-02"
  }
  landing_page_view {
    resource_name: "customer"
    unexpanded_final_url: "https://www.soomething.com/find"
  }
}

This is what I tried so far:

response = ga_service.search_stream(customer_id=customer_id, query=query)
df = pd.DataFrame()
for batch in response:
    for row in batch.results:
        df= pd.DataFrame({"Date": row.segments.date,
                          "Landing page": row.landing_page_view.unexpanded_final_url,
                          "clicks": row.metrics.clicks,
                          "conversions": row.metrics.conversions,
                          "conversion value": row.metrics.conversions_value,
                          "costs": row.metrics.cost_micros ,
                          "impressions": row.metrics.impressions},index=[0])
        final = df.append(df)

final

But the results looks like just one row of data in dataframe instead 7 days worth of data.

But if i do print(batch) i get the response as json i mention above.

How do i parse all data from json into dataframe?

Thank you in advance


Your approach is straight forward but you are appending the new row into df instead into the final Dataframe:

So do this:

final = final.append(df).reset_index(drop=True)

Instead of this:

final = df.append(df)