text_html_output_1.png
from sklearn.preprocessing import MinMaxScaler

import pandas as pd

import seaborn as sns

import statsmodels.formula.api as smf

df = pd.read_csv('../input/top-50-spotify/top50.csv', encoding='latin-1')

df.sort_values(by=['Popularity'], ascending=False)

import seaborn as sns
corr = df.corr()
ax = sns.heatmap(
    corr, 
    vmin=-1, vmax=1, center=0,
    cmap=sns.diverging_palette(20, 220, n=200),
    square=True
)

import statsmodels.formula.api as smf
import statsmodels.stats.multicomp as multi
def uni_analysis(df):
    x = df.select_dtypes(include=['O'])
    p_value = []
    for i in x:
        para = 'Popularity ~ ' + str(i)
        model = smf.ols(formula=para, data=df)
        results = model.fit()
        p_value.append(results.f_pvalue)
    df1 = pd.DataFrame(list(zip(x, p_value)), columns=['Variable', 'p_value'])
    df1['Drop_column'] = df1['p_value'].apply(lambda x: 'True' if x > 0.05 else 'False')
    return df1

df.dtypes.value_counts()

df = pd.get_dummies(df)

df = df.reindex(sorted(df.columns), axis=1)

from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler(feature_range=(0, 1))

scaled_df = scaler.transform(df)

scaled_df = pd.DataFrame(scaled_df, columns=df.columns)

scaled_df.head()