Q- now i want to get the context from my notebook so far ? 

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns




import pandas as pd


path = "data/data.xlsx"
df = pd.read_excel(path)
df = pd.DataFrame(df)
df.head()


df.shape


df.info()



<class 'pandas.core.frame.DataFrame'>
RangeIndex: 7043 entries, 0 to 7042
Data columns (total 33 columns):
 #   Column             Non-Null Count  Dtype  
---  ------             --------------  -----  
 0   CustomerID         7043 non-null   object 
 1   Count              7043 non-null   int64  
 2   Country            7043 non-null   object 
 3   State              7043 non-null   object 
 4   City               7043 non-null   object 
 5   Zip Code           7043 non-null   int64  
 6   Lat Long           7043 non-null   object 
 7   Latitude           7043 non-null   float64
 8   Longitude          7043 non-null   float64
 9   Gender             7043 non-null   object 
 10  Senior Citizen     7043 non-null   object 
 11  Partner            7043 non-null   object 
 12  Dependents         7043 non-null   object 
 13  Tenure Months      7043 non-null   int64  
 14  Phone Service      7043 non-null   object 
 15  Multiple Lines     7043 non-null   object 
 16  Internet Service   7043 non-null   object 
 17  Online Security    7043 non-null   object 
 18  Online Backup      7043 non-null   object 
 19  Device Protection  7043 non-null   object 
 20  Tech Support       7043 non-null   object 
 21  Streaming TV       7043 non-null   object 
 22  Streaming Movies   7043 non-null   object 
 23  Contract           7043 non-null   object 
 24  Paperless Billing  7043 non-null   object 
 25  Payment Method     7043 non-null   object 
 26  Monthly Charges    7043 non-null   float64
 27  Total Charges      7043 non-null   object 
 28  Churn Label        7043 non-null   object 
 29  Churn Value        7043 non-null   int64  
 30  Churn Score        7043 non-null   int64  
 31  CLTV               7043 non-null   int64  
 32  Churn Reason       1869 non-null   object 
dtypes: float64(3), int64(6), object(24)
memory usage: 1.8+ MB


"""
Notice : Total Charges column has a object data type but it is numerical data ,
dp let's change data type for this column


"""
df['Total Charges'] = pd.to_numeric(df['Total Charges'], errors='coerce')

df.describe()


from typing import Iterable, List
def calculate_null_percentage(column: Iterable) -> float:
    """
    Compute the percentage of null values in a dataframe column.
   
    Args:
    column (Iterable): A column from a dataframe
   
    Returns:
    float: The percentage of null values in the column
    """
    total_count = sum(1 for _ in column)
    null_count = sum(1 for value in column if pd.isna(value))
    return (null_count / total_count) * 100 if total_count > 0 else 0


# Now we have calculate_null_percentage(column) as a higher-order function
# We can use it in any dataframe column
# Leveraging the higher-order function principle
# We can use it in any dataframe column
# Type hints have been added to it
percentage_list: List[float] = df.apply(lambda x: calculate_null_percentage(x), axis=0)
percentage_list




CustomerID            0.000000
Count                 0.000000
Country               0.000000
State                 0.000000
City                  0.000000
Zip Code              0.000000
Lat Long              0.000000
Latitude              0.000000
Longitude             0.000000
Gender                0.000000
Senior Citizen        0.000000
Partner               0.000000
Dependents            0.000000
Tenure Months         0.000000
Phone Service         0.000000
Multiple Lines        0.000000
Internet Service      0.000000
Online Security       0.000000
Online Backup         0.000000
Device Protection     0.000000
Tech Support          0.000000
Streaming TV          0.000000
Streaming Movies      0.000000
Contract              0.000000
Paperless Billing     0.000000
Payment Method        0.000000
Monthly Charges       0.000000
Total Charges         0.156183
Churn Label           0.000000
Churn Value           0.000000
Churn Score           0.000000
CLTV                  0.000000
Churn Reason         73.463013
dtype: float64


Q- what is the best method to deal with “Total Charges” 15% present of null values ? 

Q- can you have the best suggesting ?