Hello,
I am not sure why but my x axis ‘date’ doesn’t have units along the axis? Does anyone know how I can fix this? Other than that the graph is completely fine.
SORTED!
Import data (Make sure to parse dates. Consider setting index column to ‘date’.)
df = pd.read_csv(‘fcc-forum-pageviews.csv’, parse_dates=[‘date’])
df = df.set_index(‘date’)
– that fixed it. I forgot to parse the date. So if this happens to anyone else this is how I sorted it
Your code so far
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 = df.set_index('date')
# Clean data
df = df[(df['value'] >= df['value'].quantile(0.025))
& (df['value'] <= df['value'].quantile(0.975))]
def draw_line_plot():
# Draw line plot
fig, ax = plt.subplots(figsize=(20, 10))
plt.plot(df, color='r')
plt.title('Daily freeCodeCamp Forum Page Views 5/2016-12/2019')
plt.xlabel('Date')
plt.ylabel('Page Views')
# Save image and return fig (don't change this part)
fig.savefig('line_plot.png')
return fig
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36
.
Challenge: Page View Time Series Visualizer
Link to the challenge: