Time_series_visualizer console not running (frozen) & not .png files saved

Good morning,
I have coded this project on my Idle in my pc and is running, but when I run in repl. the console after downloading the libraries and dependences, remain blocked, not error, but not ok. Not exit at all. Nothing.
Then, I can observe that the 3 files .png with the figures created in matplot have not been saved, not even appear my 3 .png files, just only the examples. The link to my code is:
Replit - boilerplate-page-view-time-series-visualizer-1
But, as every time I access repl. ,my last code has disappeared and it shows just the proposed exercise, I copy and paste, all my code:

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()

Import data (Make sure to parse dates. Consider setting index column to ‘date’.)

df = pd.read_csv(‘fcc-forum-pageviews.csv’)
df[‘date’]=pd.to_datetime(df[‘date’])
#df[‘month’]=df[‘date’].dt.month
#df[‘year’]=df[‘date’].dt.year
df.set_index(‘date’,inplace=True)
#print(df.dtypes)
#print(df.index)
#print (df.info())

Clean data

df = df[(df[‘value’]<=df[‘value’].quantile(0.975))& (df[‘value’]>=df[‘value’].quantile(0.025))]
print(df)

def draw_line_plot():
# Draw line plot
df[‘value’].plot(color=‘maroon’)
plt.xlabel(‘Date’, labelpad=14)
plt.ylabel(‘Page View’, labelpad=8)
plt.title(‘Daily freeCodeCamp Forum Page Views 5/2016-12/2019’)
plt.show()

fig=plt.figure().show()

# Save image and return fig (don't change this part)
fig.savefig('line_plot.png')
return fig

def draw_bar_plot():
# Copy and modify data for monthly bar plot

df_b=df.copy()
df_b.reset_index(inplace=True)
df_b['year']= df_b['date'].dt.year
df_b['Months']= df_b['date'].dt.month
df_b.set_index('date', inplace=True)
df_bar=df_b.resample('M').mean()
df_bar['year']=df_bar['year'].astype(int)

df_bar['Months']=df_bar['Months'].replace(1.0,'January')
df_bar['Months']=df_bar['Months'].replace(2.0,'February')
df_bar['Months']=df_bar['Months'].replace(3.0,'March')
df_bar['Months']=df_bar['Months'].replace(4.0,'April')
df_bar['Months']=df_bar['Months'].replace(5.0,'May')
df_bar['Months']=df_bar['Months'].replace(6.0,'June')
df_bar['Months']=df_bar['Months'].replace(7.0,'July')
df_bar['Months']=df_bar['Months'].replace(8.0,'August')
df_bar['Months']=df_bar['Months'].replace(9.0,'September')
df_bar['Months']=df_bar['Months'].replace(10.0,'October')
df_bar['Months']=df_bar['Months'].replace(11.0,'November')
df_bar['Months']=df_bar['Months'].replace(12.0,'Dicember')

#df_b = df.groupby(df['month']).mean()
#print(df_b)
#print(df_bar)

Draw bar plot

g=sns.catplot(x='year', y='value', data=df_bar, kind='bar', hue='Months')
g.set(xlabel='Years')
g.set(ylabel='Average Page Views')

#plt.show()

fig=plt.figure().show()

Save image and return fig (don’t change this part)

fig.savefig('bar_plot.png')
return fig

def draw_box_plot():
# Prepare data for box plots (this part is done!)
df_box = df.copy()
df_box.reset_index(inplace=True)
df_box[‘year’] = [d.year for d in df_box.date]
df_box[‘month’] = [d.strftime(’%b’) for d in df_box.date]

# Draw box plots (using Seaborn)
plt.subplot(1,2,1)
fig1=sns.boxplot(x=df_box['year'], y=df_box['value'])
fig1.set(xlabel='Years', ylabel='Page Views')
fig1.axes.set_title('Year-wise Box Plot(Trend)')
plt.subplot(1,2,2)
fig2=sns.boxplot(x='month', y='value', data=df_box, order=['Jan','Feb','Mar','Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'])
fig2.set (xlabel='Month', ylabel='Page Views')
fig2.axes.set_title('Month-wise Box Plot (Seasonality')
plt.show()

fig=plt.figure().show()

Save image and return fig (don’t change this part)

fig.savefig('box_plot.png')
return fig

Not sure if it is completly good or not, but please help me, because is fustrating don´t having any feedback from the console.

Execution is stopped, because show method blocks further execution for as long as plot is displayed. Displaying plot this way is not necessary nor desired in this project.

Thank very much. Already running. That was because running in my Idle I did´nt create the methods that were called from main. I just ran the view_time_series_visualizer without methods and without main, and to show the graphics I just used them. After I forgot to change to “#”.
Well, now I have the same error for all of them when the module test is running:
self.ax= self.fig.axes[0] list index out of range. But, it is just checking what is wrong, at least I am already notify.
Thank you very much. Good weekend.

Hello, were you ever able to figure out what the issue was and run your tests?

Yes. Thank you Isaiahn. I already finished all the projects of Data Analysis.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.