# Import libraries
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder, StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report, accuracy_score, confusion_matrix
from sklearn.cluster import KMeans
from scipy.stats import ttest_ind

# Set visualization style
sns.set(style="whitegrid", palette="pastel")

# Load the dataset
file_path = "Telco_customer_churn.csv"
df = pd.read_csv(file_path)

# Display basic info
print("Dataset Overview:")
print(df.info())
print(df.head())

# Check for missing values
print("Missing values:", df.isnull().sum())

# Drop unnecessary columns
df.drop(['CustomerID', 'Lat Long', 'Latitude', 'Longitude', 'Zip Code'], axis=1, inplace=True)

# Fill missing Total Charges with median
df['Total Charges'] = pd.to_numeric(df['Total Charges'], errors='coerce')
df['Total Charges'].fillna(df['Total Charges'].median(), inplace=True)

# Encode categorical features
categorical_cols = df.select_dtypes(include=['object']).columns
label_encoders = {}
for col in categorical_cols:
    label_encoders[col] = LabelEncoder()
    df[col] = label_encoders[col].fit_transform(df[col])

# Feature scaling for numeric features
scaler = StandardScaler()
df[['Monthly Charges', 'Total Charges', 'Tenure Months']] = scaler.fit_transform(
    df[['Monthly Charges', 'Total Charges', 'Tenure Months']]
)

# Visualize churn distribution
plt.figure(figsize=(8, 5))
sns.countplot(data=df, x='Churn Label')
plt.title("Churn Distribution")
plt.show()

# Correlation heatmap
plt.figure(figsize=(18, 12))
sns.heatmap(df.corr(), annot=True, fmt=".2f", cmap="coolwarm")
plt.title("Feature Correlation Heatmap")
plt.show()

# Churn by payment method
# Map encoded values back to original text for Payment Method
payment_method_mapping = dict(zip(label_encoders['Payment Method'].classes_, range(len(label_encoders['Payment Method'].classes_))))
reverse_payment_method_mapping = {v: k for k, v in payment_method_mapping.items()}

# Replace numbers with text in the dataframe
df['Payment Method Text'] = df['Payment Method'].map(reverse_payment_method_mapping)

# Replot with text labels
plt.figure(figsize=(10, 6))
sns.countplot(data=df, x='Payment Method Text', hue='Churn Label')
plt.title("Churn by Payment Method")
plt.xlabel("Payment Method")
plt.show()

# Churn rate by Gender
plt.figure(figsize=(6,4))
sns.countplot(x='Gender', hue='Churn Label', data=df)
plt.title('Churn by Gender')
plt.xlabel('Gender')
plt.ylabel('Count')
plt.legend(['No Churn', 'Churn'])
plt.show()

# Churn rate by Contract Type
plt.figure(figsize=(8,6))
sns.countplot(x='Contract', hue='Churn Label', data=df)
plt.title('Churn by Contract Type')
plt.xlabel('Contract Type')
plt.ylabel('Count')
plt.legend(['No Churn', 'Churn'])
plt.show()

# Boxplot for Monthly Charges
plt.figure(figsize=(8,6))
sns.boxplot(x='Churn Label', y='Monthly Charges', data=df)
plt.title('Monthly Charges vs Churn')
plt.xlabel('Churn')
plt.ylabel('Monthly Charges')
plt.show()

Convert the code so that it uses plotly instead of matplotlib. 

Remove all existing comments and replace them with multiple-line comments giving extremely detailed explanation of what each code does - use semi-formal tone.