Posts tagged with pandas

I need to import pandas and google ads in the AWS lambda function. pandas support only the 3.7 version and google ads support only the 3.8 version.

When I've given lambda 3.8 version google ads works and pandas get an error and when I'm given lambda 3.7 version pandas works and google ads get an error.

Please guide me on how to support the two versions of layers.

I have encounter a problem with the google ads report and I have no clue how to fix it... I use the following code to extract the data from google ads via API call

import sys from googleads import adwords import pandas as pd import pandas as np import io output = io.StringIO() def main(client):   # Initialize appropriate service.   report_downloader = client.GetReportDownloader(version='v201809')   # Create report query.   report_query = (adwords.ReportQueryBuilder()                   .Select('CampaignId', 'AdGroupId', 'Id', 'Criteria',                           'CriteriaType', 'FinalUrls', 'Impressions', 'Clicks',                           'Cost')                   .From('CRITERIA_PERFORMANCE_REPORT')                   .Where('Status').In('ENABLED', 'PAUSED')                   .During('LAST_7_DAYS')                   .Build())   # You can provide a file object to write the output to. For this   # demonstration we use sys.stdout to write the report to the screen.   report_downloader.DownloadReportWithAwql(       report_query, 'CSV', output, skip_report_header=False,       skip_column_header=False, skip_report_summary=False,       include_zero_impressions=True)   output.seek(0)   df = pd.read_csv(output)   df = df.to_csv('results.csv') if __name__ == '__main__':   # Initialize client object.   adwords_client = adwords.AdWordsClient.LoadFromStorage()   main(adwords_client) 

the code works as expected and pulls the data and save it in a CSV file, however, when I access the columns it prints just one column 'CRITERIA_PERFORMANCE_REPORT (Nov 5, 2019-Nov 11, 2019)' when I open the csv file looks like this

result.csv

I have tried to drop the first row with df.drop(df.index[0]) to access the rest of the data however nothing seems to be working. is there any way I can remove the first row or change to use the second row as the columns names which is the result I expected.

thanks in advance