My following code is not giving desired output
Data_file contains all youtube channel, their subscribers and number of views
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data_file = pd.read_csv(‘YOUTUBE CHANNELS DATASET.csv’)
df = pd.DataFrame(data_file)
df[‘Views’] = df[‘Views’].str.replace(‘,’,”, regex = True)
df[‘Views’] = pd.to_numeric(df[‘Views’], errors = ‘coerce’).fillna(0)
y = df[‘Views’].astype(int)
df[‘log_views’] = np.log10(df[‘Views’].where(df[‘Views’] > 0, np.nan))
df[‘Uploads’] = df[‘Uploads’].str.replace(‘,’,”, regex = True)
df[‘Uploads’] = pd.to_numeric(df[‘Uploads’], errors = ‘coerce’).fillna(0)
x1 = df[‘Uploads’].astype(int)
plt.figure (figsize = (10,8))
plt.scatter (x1, y, s = df[‘log_views’], edgecolor = ‘w’, linewidth = 0.5, alpha = 0.87, cmap = ‘viridis’ )
Please suggest where I am going wrong
submitted by /u/bull_bear25
[link] [comments]
r/learnpython My following code is not giving desired output Data_file contains all youtube channel, their subscribers and number of views import pandas as pd import numpy as np import matplotlib.pyplot as plt data_file = pd.read_csv(‘YOUTUBE CHANNELS DATASET.csv’) df = pd.DataFrame(data_file) df[‘Views’] = df[‘Views’].str.replace(‘,’,”, regex = True) df[‘Views’] = pd.to_numeric(df[‘Views’], errors = ‘coerce’).fillna(0) y = df[‘Views’].astype(int) df[‘log_views’] = np.log10(df[‘Views’].where(df[‘Views’] > 0, np.nan)) df[‘Uploads’] = df[‘Uploads’].str.replace(‘,’,”, regex = True) df[‘Uploads’] = pd.to_numeric(df[‘Uploads’], errors = ‘coerce’).fillna(0) x1 = df[‘Uploads’].astype(int) plt.figure (figsize = (10,8)) plt.scatter (x1, y, s = df[‘log_views’], edgecolor = ‘w’, linewidth = 0.5, alpha = 0.87, cmap = ‘viridis’ ) Please suggest where I am going wrong submitted by /u/bull_bear25 [link] [comments]
My following code is not giving desired output
Data_file contains all youtube channel, their subscribers and number of views
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data_file = pd.read_csv(‘YOUTUBE CHANNELS DATASET.csv’)
df = pd.DataFrame(data_file)
df[‘Views’] = df[‘Views’].str.replace(‘,’,”, regex = True)
df[‘Views’] = pd.to_numeric(df[‘Views’], errors = ‘coerce’).fillna(0)
y = df[‘Views’].astype(int)
df[‘log_views’] = np.log10(df[‘Views’].where(df[‘Views’] > 0, np.nan))
df[‘Uploads’] = df[‘Uploads’].str.replace(‘,’,”, regex = True)
df[‘Uploads’] = pd.to_numeric(df[‘Uploads’], errors = ‘coerce’).fillna(0)
x1 = df[‘Uploads’].astype(int)
plt.figure (figsize = (10,8))
plt.scatter (x1, y, s = df[‘log_views’], edgecolor = ‘w’, linewidth = 0.5, alpha = 0.87, cmap = ‘viridis’ )
Please suggest where I am going wrong
submitted by /u/bull_bear25
[link] [comments]