<jupyter_start><jupyter_text>Lectura de archivos<jupyter_code>def read_datasets(files_to_read):
    dataframes = {}
    not_working = []
    for file in files_to_read:
        try:
            df = pd.read_csv(file, sep="|")
            df["origin"] = file
            dataframes[file.split("/")[-1]] = df
        except Exception as e:
            print(e)
            not_working.append(file)

    return dataframes, not_working
files = list(pathlib.Path("../..").joinpath("data").joinpath("raw").iterdir())
files = list(filter(lambda x: not str(x).split("/")[-1].startswith("."), files))
files = list(map(lambda x: str(x.resolve()), files))
dfs, nw = read_datasets(files)
list(dfs.keys())<jupyter_output><empty_output><jupyter_text>Limpieza<jupyter_code>for key in dfs:
    dfs[key]["symbol"] = dfs[key]["symbol"].apply(lambda x: x.replace("$", ""))
    dfs[key]["price"] = dfs[key]["price"].apply(lambda x: float(str(x).replace(",", "")))<jupyter_output><empty_output><jupyter_text>Procesamiento  Chasis<jupyter_code>chasis_df = dfs["amazon_chasis_para_pc.csv"]
chasis_df["type"] = "Chasis"
chasis_df = chasis_df[chasis_df["price"] >= 100]
chasis_df = chasis_df[~(chasis_df["title"].str.contains("mine") | chasis_df["title"].str.contains("Server"))]
chasis_df.loc[:, "category"] = ""
chasis_df.loc[chasis_df["price"] <= 200, "category"] = "Office"
chasis_df.loc[chasis_df["price"] > 200, "category"] = "Gamer"
chasis_df.loc[:, "range"] = ""
chasis_df.loc[chasis_df["price"] <= 250, "range"] = "Low"
chasis_df.loc[(chasis_df["price"] > 250) & (chasis_df["price"] <= 500), "range"] = "Mid"
chasis_df.loc[chasis_df["price"] > 500, "range"] = "High"
chasis_df = chasis_df[ORDERED_COLUMNS]
dfs["amazon_chasis_para_pc.csv"] = chasis_df
dfs["amazon_chasis_para_pc.csv"]<jupyter_output><empty_output><jupyter_text>Almacenamiento  SSD<jupyter_code>ssd_df = dfs["amazon_nvme_m.2.csv"]
ssd_df = ssd_df[(ssd_df["title"].str.contains("GB")) | (ssd_df["title"].str.contains("TB"))]
ssd_df.loc[:, "type"] = "Storage"
ssd_df.loc[:, "category"] = ""
ssd_df.loc[ssd_df["price"] <= 200, "category"] = "Stream"
ssd_df.loc[(ssd_df["price"] > 200) & (ssd_df["price"] <= 550), "category"] = "Gamer"
ssd_df.loc[ssd_df["price"] > 550, "category"] = "Desing"
ssd_df.loc[:, "range"] = ""
ssd_df.loc[ssd_df["price"] <= 250, "range"] = "Mid"
ssd_df.loc[ssd_df["price"] > 250, "range"] = "High"
ssd_df
dfs["amazon_nvme_m.2.csv"] = ssd_df[ORDERED_COLUMNS]
dfs["amazon_nvme_m.2.csv"]<jupyter_output><empty_output><jupyter_text>HDD<jupyter_code>hdd_df = dfs["amazon_hdd_interno.csv"]
hdd_df = hdd_df[(~hdd_df["title"].str.contains("exte")) & (hdd_df["price"] > 20)]
hdd_df.loc[:, "type"] = "Storage"
hdd_df
hdd_df.loc[:, "category"] = ""
hdd_df.loc[hdd_df["price"] <= 50, "category"] = "Office"
hdd_df.loc[(hdd_df["price"] > 50) & (hdd_df["price"] <= 200), "category"] = "Gamer"
hdd_df.loc[hdd_df["price"] > 200, "category"] = "Desing"
hdd_df.loc[:, "range"] = ""
hdd_df.loc[hdd_df["price"] <= 35, "range"] = "Low"
hdd_df.loc[(hdd_df["price"] > 35) & (hdd_df["price"] <= 100), "range"] = "Mid"
hdd_df.loc[hdd_df["price"] > 100, "range"] = "High"
dfs["amazon_hdd_interno.csv"] = hdd_df[ORDERED_COLUMNS]
hdd_df<jupyter_output><empty_output><jupyter_text>Tarjeta grafica<jupyter_code>gpu_df = dfs["amazon_tarjetas_graficas.csv"]
gpu_df = gpu_df[gpu_df["price"] > 150]
gpu_df.loc[:, "type"] = "GPU"
gpu_df.loc[:, "category"] = 'Gamer/Desing'
gpu_df
gpu_df.loc[:, "range"] = ""
gpu_df.loc[gpu_df["price"] <= 250, "range"] = "Low"
gpu_df.loc[(gpu_df["price"] > 250) & (gpu_df["price"] <= 700), "range"] = "Mid"
gpu_df.loc[gpu_df["price"] > 700, "range"] = "High"
dfs["amazon_tarjetas_graficas.csv"] = gpu_df[ORDERED_COLUMNS]
dfs["amazon_tarjetas_graficas.csv"]<jupyter_output><empty_output><jupyter_text>Fuentes de alimentación<jupyter_code>power_df = dfs["amazon_fuentes_de_alimentacion_para_pc.csv"]
power_df = power_df[power_df["price"] > 100]
power_df.loc[:, "type"] = "Power Supply"
power_df.loc[:, "category"] = ""
power_df.loc[power_df["price"] <= 250, "category"] = "Office"
power_df.loc[power_df["price"] > 250, "category"] = "Gamer"
power_df.loc[:, "range"] = ""
power_df.loc[power_df["price"] <= 250, "range"] = "Low"
power_df.loc[(power_df["price"] > 250) & (power_df["price"] <= 400), "range"] = "Mid"
power_df.loc[power_df["price"] > 400, "range"] = "High"
dfs["amazon_fuentes_de_alimentacion_para_pc.csv"] = power_df[ORDERED_COLUMNS]
dfs["amazon_fuentes_de_alimentacion_para_pc.csv"]<jupyter_output><empty_output><jupyter_text>Refrigeración<jupyter_code>ref_df = dfs["amazon_refrigeracion_pc.csv"]
ref_df = ref_df[ref_df["price"] > 100]
ref_df.loc[:, "type"] = "Refrigeration"
ref_df.loc[:, "category"] = ""
ref_df.loc[ref_df["price"] <= 200, "category"] = "Office"
ref_df.loc[ref_df["price"] > 200, "category"] = "Gamer"
ref_df.loc[:, "range"] = ""
ref_df.loc[ref_df["price"] <= 150, "range"] = "Low"
ref_df.loc[(ref_df["price"] > 150) & (ref_df["price"] <= 400), "range"] = "Mid"
ref_df.loc[ref_df["price"] > 400, "range"] = "High"
dfs["amazon_refrigeracion_pc.csv"] = ref_df[ORDERED_COLUMNS]
dfs["amazon_refrigeracion_pc.csv"]<jupyter_output><empty_output><jupyter_text>RAM<jupyter_code>ram_df = dfs["amazon_memorias_ram_dd4.csv"]
ram_df = ram_df[(ram_df["price"] > 50) & (ram_df["title"].str.contains("GB"))]
ram_df.loc[:, "type"] = "RAM"
ram_df.loc[:, "category"] = ""
ram_df.loc[ram_df["price"] <= 250, "category"] = "Office"
ram_df.loc[ram_df["price"] > 250, "category"] = "Gamer"
ram_df.loc[:, "range"] = ""
ram_df.loc[ram_df["price"] <= 150, "range"] = "Low"
ram_df.loc[(ram_df["price"] > 150) & (ram_df["price"] <= 600), "range"] = "Mid"
ram_df.loc[ram_df["price"] > 600, "range"] = "High"
dfs["amazon_memorias_ram_dd4.csv"] = ram_df[ORDERED_COLUMNS]
dfs["amazon_memorias_ram_dd4.csv"] 
ram_df<jupyter_output><empty_output><jupyter_text>Procesador<jupyter_code>cpu_df = dfs["amazon_procesadores.csv"]
cpu_df = cpu_df[cpu_df["price"] > 100]
cpu_df.loc[:, "type"] = "CPU"
cpu_df.loc[:, "category"] = ""
cpu_df.loc[cpu_df["price"] <= 150, "category"] = "Office"
cpu_df.loc[cpu_df["price"] > 150, "category"] = "Gamer"
cpu_df.loc[:, "range"] = ""
cpu_df.loc[cpu_df["price"] <= 150, "range"] = "Low"
cpu_df.loc[(cpu_df["price"] > 150) & (cpu_df["price"] <= 300), "range"] = "Mid"
cpu_df.loc[cpu_df["price"] > 300, "range"] = "High"
dfs["amazon_procesadores.csv"] = cpu_df[ORDERED_COLUMNS]
dfs["amazon_procesadores.csv"]<jupyter_output><empty_output><jupyter_text>Placas<jupyter_code>board_df = dfs["amazon_tarjeta_madre.csv"]
board_df = board_df[board_df["price"] > 100]
board_df.loc[:, "type"] = "Mother Board"
board_df.loc[:, "category"] = ""
board_df.loc[board_df["price"] <= 150, "category"] = "Office"
board_df.loc[board_df["price"] > 150, "category"] = "Gamer"
board_df.loc[:, "range"] = ""
board_df.loc[board_df["price"] <= 150, "range"] = "Low"
board_df.loc[(board_df["price"] > 150) & (board_df["price"] <= 300), "range"] = "Mid"
board_df.loc[board_df["price"] > 300, "range"] = "High"
dfs["amazon_tarjeta_madre.csv"] = board_df[ORDERED_COLUMNS]
dfs["amazon_tarjeta_madre.csv"]<jupyter_output><empty_output><jupyter_text>Export results<jupyter_code>df = pd.concat(dfs.values()).reset_index(drop=True)
df
df.to_csv("/work/games_seeker/data/interim/pc_components.csv", sep="|", index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22305798687089715, 'fraction_numerical': 0.025711159737417943, 'mean_word_length': 7.493612078977932, 'pattern_counts': {'":': 0, '<': 76, '<?xml version=': 0, '>': 84, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '605141', 'license': 'MIT', 'n_tokens_mistral': 3272, 'n_tokens_neox': 3113, 'n_words': 402, 'path': 'notebooks/preprocessing/01_initial.ipynb', 'repo_name': 'sgg10/games_seeker', 'size': '7312'}