From 36a101c12d945012ce04c0185934b8bfcd5048b2 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 5 Oct 2023 11:23:39 +0800 Subject: [PATCH] better way to check if can concat game genres --- adscrawler/app_stores/apple.py | 13 ++++++------- adscrawler/app_stores/scrape_stores.py | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/adscrawler/app_stores/apple.py b/adscrawler/app_stores/apple.py index 5bb70eb..d8be502 100644 --- a/adscrawler/app_stores/apple.py +++ b/adscrawler/app_stores/apple.py @@ -1,6 +1,5 @@ import re -import numpy as np import pandas as pd from itunes_app_scraper.scraper import AppStoreScraper from itunes_app_scraper.util import AppStoreCategories, AppStoreCollections @@ -133,13 +132,13 @@ def clean_ios_app_df(df: pd.DataFrame) -> pd.DataFrame: if "price" not in df.columns: df["price"] = 0 try: - df["category"] = np.where( - df["category"] == "Games", - "game_" + df["genres"].apply(lambda x: x.split(",")[1]), - df["category"], - ) + df.loc[df["category"] == "Games", "category"] = "game_" + df.loc[ + df["category"] == "Games", "genres" + ].apply(lambda x: x.split(",")[1]) except Exception as e: - logger.warning(f"Split genre ID for iOS Game didn't work {e}") + logger.warning( + f"store_id={df['store_id'].values[0]} split genre IDs failed {e}" + ) df = df.assign( free=df["price"] == 0, developer_id=df["developer_id"].astype(str), diff --git a/adscrawler/app_stores/scrape_stores.py b/adscrawler/app_stores/scrape_stores.py index 66c4eb7..6f50680 100644 --- a/adscrawler/app_stores/scrape_stores.py +++ b/adscrawler/app_stores/scrape_stores.py @@ -344,4 +344,5 @@ def log_crawl_results(app_df: pd.DataFrame, database_connection: PostgresCon) -> "in_app_purchases", "editors_choice", "crawl_result", + "icon_url_512", ]