252 lines
8.3 KiB
Plaintext
252 lines
8.3 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "c4205b5d-e052-4863-a46b-20e4757052a7",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Business Data Challenge - Team 1"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"id": "ae3af8e6-ced8-4994-8877-fa98d4297cc0",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"import numpy as np"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "dd3184e7-54a1-4463-af42-5850d9517a41",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Configuration de l'accès aux données"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "b6035982-9ff4-4013-9792-2d50e10db3d1",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"['bdc2324-data/1/1campaign_stats.csv',\n",
|
||
|
" 'bdc2324-data/1/1campaigns.csv',\n",
|
||
|
" 'bdc2324-data/1/1categories.csv',\n",
|
||
|
" 'bdc2324-data/1/1countries.csv',\n",
|
||
|
" 'bdc2324-data/1/1currencies.csv',\n",
|
||
|
" 'bdc2324-data/1/1customer_target_mappings.csv',\n",
|
||
|
" 'bdc2324-data/1/1customersplus.csv',\n",
|
||
|
" 'bdc2324-data/1/1event_types.csv',\n",
|
||
|
" 'bdc2324-data/1/1events.csv',\n",
|
||
|
" 'bdc2324-data/1/1facilities.csv',\n",
|
||
|
" 'bdc2324-data/1/1link_stats.csv',\n",
|
||
|
" 'bdc2324-data/1/1pricing_formulas.csv',\n",
|
||
|
" 'bdc2324-data/1/1product_packs.csv',\n",
|
||
|
" 'bdc2324-data/1/1products.csv',\n",
|
||
|
" 'bdc2324-data/1/1products_groups.csv',\n",
|
||
|
" 'bdc2324-data/1/1purchases.csv',\n",
|
||
|
" 'bdc2324-data/1/1representation_category_capacities.csv',\n",
|
||
|
" 'bdc2324-data/1/1representations.csv',\n",
|
||
|
" 'bdc2324-data/1/1seasons.csv',\n",
|
||
|
" 'bdc2324-data/1/1structure_tag_mappings.csv',\n",
|
||
|
" 'bdc2324-data/1/1suppliers.csv',\n",
|
||
|
" 'bdc2324-data/1/1tags.csv',\n",
|
||
|
" 'bdc2324-data/1/1target_types.csv',\n",
|
||
|
" 'bdc2324-data/1/1targets.csv',\n",
|
||
|
" 'bdc2324-data/1/1tickets.csv',\n",
|
||
|
" 'bdc2324-data/1/1type_of_categories.csv',\n",
|
||
|
" 'bdc2324-data/1/1type_of_pricing_formulas.csv',\n",
|
||
|
" 'bdc2324-data/1/1type_ofs.csv']"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import os\n",
|
||
|
"import s3fs\n",
|
||
|
"# Create filesystem object\n",
|
||
|
"S3_ENDPOINT_URL = \"https://\" + os.environ[\"AWS_S3_ENDPOINT\"]\n",
|
||
|
"fs = s3fs.S3FileSystem(client_kwargs={'endpoint_url': S3_ENDPOINT_URL})\n",
|
||
|
"\n",
|
||
|
"BUCKET = \"bdc2324-data/1\"\n",
|
||
|
"fs.ls(BUCKET)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"id": "b86c935d-124f-453f-80dd-83ea6770d09c",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"dic_base=['campaign_stats','campaigns','categories','countries','currencies','customer_target_mappings','customersplus','event_types','events','facilities','link_stats','pricing_formulas','product_packs','products','products_groups','purchases','representation_category_capacities','representations','seasons','structure_tag_mappings','suppliers','tags','target_types','targets','tickets','type_of_categories','type_of_pricing_formulas','type_ofs']"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"id": "f6d0b27c-0ecd-406b-b042-6c3802dd68fd",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/tmp/ipykernel_1054/1008972637.py:5: DtypeWarning: Columns (1) have mixed types. Specify dtype option on import or set low_memory=False.\n",
|
||
|
" globals()[nom_base] = pd.read_csv(file_in, sep=\",\")\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"dic_base=['campaign_stats','campaigns','categories','countries','currencies','customer_target_mappings','customersplus','event_types','events','facilities','link_stats','pricing_formulas','product_packs','products','products_groups','purchases','representation_category_capacities','representations','seasons','structure_tag_mappings','suppliers','tags','target_types','targets','tickets','type_of_categories','type_of_pricing_formulas','type_ofs']\n",
|
||
|
"for nom_base in dic_base:\n",
|
||
|
" FILE_PATH_S3_fanta = 'bdc2324-data/1/1' + nom_base + '.csv'\n",
|
||
|
" with fs.open(FILE_PATH_S3_fanta, mode=\"rb\") as file_in:\n",
|
||
|
" globals()[nom_base] = pd.read_csv(file_in, sep=\",\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "2a6b5e22-3370-457f-83b7-dd1e13663229",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"'bdc2324-data/1/1type_ofs.csv'"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"FILE_PATH_S3_fanta"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "bcc14f93-2289-44eb-816b-a51049b258df",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Detection des valeur manquantes"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"id": "7f8083ec-3d08-4c4e-8d26-a5a4948c1c02",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"dic_prod_princing=['type_of_pricing_formulas','products_groups','pricing_formulas','product_packs','products']"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"id": "a6de36fa-3d35-4b20-97f2-3e24d54c7f99",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def verifier_donnees_manquantes(base):\n",
|
||
|
" donnees_manquantes = base.isna().sum()\n",
|
||
|
" print(\"Données manquantes pour la base :\")\n",
|
||
|
" print(donnees_manquantes)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"id": "1c261736-11fb-44f4-a4b1-830cae755a65",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"ename": "AttributeError",
|
||
|
"evalue": "'str' object has no attribute 'isna'",
|
||
|
"output_type": "error",
|
||
|
"traceback": [
|
||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||
|
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
||
|
"Cell \u001b[0;32mIn[17], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m nom_base \u001b[38;5;129;01min\u001b[39;00m dic_prod_princing:\n\u001b[0;32m----> 2\u001b[0m \u001b[43mverifier_donnees_manquantes\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnom_base\u001b[49m\u001b[43m)\u001b[49m\n",
|
||
|
"Cell \u001b[0;32mIn[16], line 2\u001b[0m, in \u001b[0;36mverifier_donnees_manquantes\u001b[0;34m(base)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mverifier_donnees_manquantes\u001b[39m(base):\n\u001b[0;32m----> 2\u001b[0m donnees_manquantes \u001b[38;5;241m=\u001b[39m \u001b[43mbase\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43misna\u001b[49m()\u001b[38;5;241m.\u001b[39msum()\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDonnées manquantes pour la base :\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(donnees_manquantes)\n",
|
||
|
"\u001b[0;31mAttributeError\u001b[0m: 'str' object has no attribute 'isna'"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"for nom_base in dic_prod_princing:\n",
|
||
|
" verifier_donnees_manquantes(nom_base)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"id": "e0c67c01-e837-4772-b070-d1be0d895a36",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"id 0\n",
|
||
|
"type_of_id 0\n",
|
||
|
"pricing_formula_id 0\n",
|
||
|
"created_at 0\n",
|
||
|
"updated_at 0\n",
|
||
|
"identifier 0\n",
|
||
|
"dtype: int64"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"type_of_pricing_formulas.isna().sum()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "57298669-8d55-40d5-a5aa-4c5df984eec7",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.10.13"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|