<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Exploring Movie Data
Timothy Helton
Exploring and visualizing movie data scraped from Box Office Mojo. Make sure to format your plots properly with axis labels and graph titles at the very least.
<br>
<font color="red">
    NOTE
Step1:  Data Prep
Load the dataset and explore its contents, columns and types. Convert any date columns from string to Python's datetime.
Step2:  Exercise 1
Plot the Domestic Total Gross by Release Date. Try a scatterplot and a line plot. In what scale are the numbers on the Y axis?
Step3:  Y-Axis Labels
The y-axis labels are scaled to millions of dollars.
Exercise 2
Plot the Domestic Total Gross by Runtime. Plot Runtime vs Release Date.  Try a scatterplot and a line plot. What are the benefits and liabilities of each type of plot in this case?
Step4:  Benefits and Liabilities
The scatter plot clearly bins the data allowing one to observe the counts of movies at a given run time and the corresponding sales.
The line plot is harder to gain insight.
The overall majority of run times reside beween 100-120 minutes in length and there is not a trend over time that the run times are increasing or decreasing.
Exercise 3
The Motion Picture Association of America (MPAA) rating system comprises of G (general audiences
Step5:  Findings
Movies marketed towards adults are on average 10-15% longer than those for younger audiences.
Movies marketed towards younger audiences are far more likely to produce larger domestic gross sales.
Exercise 4
Plot the Domestic Total Gross by the Release Date. Segment by Rating - that is, have all 4 groups on the same plot. Can you spot anything out of the ordinary? Now make 4 separate plots (one for each Rating) but part of the same matplotlib figure. What are the benefits and liabilities of each approach?
Step6:  Findings
The combined plot makes details of most of the data difficult to interpret, but highlights the points that are above average.
The segregated plots require the scales to be set equal on each plot to facilitate a comparision.
By combining all these plots together a composite view of the data is formed resulting in insight.
Exercise 5
Who are the top 10 directors with the highest gross per movie (highest average gross)? How many movies did they release in that time period? Who are the top 10 directors with the highest average gross excluding one-hit wonders (directors that have a single release in the dataset)?
Step7:  Exercise 6
Group the movies by month of release and plot the mean Domestic Total Gross by month. Calculate the Standard Error and add error bars to the plot. Can you tell any pattern from the data?
<ASSISTANT_TASK:>
Python Code:
from k2datascience import movies
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
%matplotlib inline
Explanation: Exploring Movie Data
Timothy Helton
Exploring and visualizing movie data scraped from Box Office Mojo. Make sure to format your plots properly with axis labels and graph titles at the very least.
<br>
<font color="red">
    NOTE:
    <br>
    This notebook uses code found in the
    <a href="https://github.com/TimothyHelton/k2datascience/blob/master/k2datascience/movies.py">
    <strong>k2datascience.movies</strong></a> module.
    To execute all the cells do one of the following items:
    <ul>
        <li>Install the k2datascience package to the active Python interpreter.</li>
        <li>Add k2datascience/k2datascience to the PYTHON_PATH system variable.</li>
        <li>Create a link to the movies.py file in the same directory as this notebook.</li>
</font>
Imports
End of explanation
mov = movies.BoxOffice()
print(f'Data Types:\n{mov.data.dtypes}\n\n')
print(f'Data Shape:\n{mov.data.shape}\n\n')
print(f'Missing Data:\n{mov.data.isnull().sum()}\n\n')
mov.data.head()
mov.data.tail()
mov.data.describe()
mov.distribution_plot()
mov.kde_plot()
Explanation: Data Prep
Load the dataset and explore its contents, columns and types. Convert any date columns from string to Python's datetime.
End of explanation
mov.domestic_gross_vs_release_date_plot()
Explanation: Exercise 1
Plot the Domestic Total Gross by Release Date. Try a scatterplot and a line plot. In what scale are the numbers on the Y axis?
End of explanation
mov.domestic_gross_vs_runtime_plot()
mov.runtime_vs_release_plot()
Explanation: Y-Axis Labels
The y-axis labels are scaled to millions of dollars.
Exercise 2
Plot the Domestic Total Gross by Runtime. Plot Runtime vs Release Date.  Try a scatterplot and a line plot. What are the benefits and liabilities of each type of plot in this case?
End of explanation
mov.rating_plot()
Explanation: Benefits and Liabilities
The scatter plot clearly bins the data allowing one to observe the counts of movies at a given run time and the corresponding sales.
The line plot is harder to gain insight.
The overall majority of run times reside beween 100-120 minutes in length and there is not a trend over time that the run times are increasing or decreasing.
Exercise 3
The Motion Picture Association of America (MPAA) rating system comprises of G (general audiences: all ages admitted), PG (parental guidance suggested: may not be suitable for children), PG-13 (parents stronly cautioned: may be inappropriate for children under 13), and R (restricted: under 17 requires accompanying parent or adult guardian). Find the average Runtime and Domestic Total Gross at each Rating Level. Plot both by Rating. Do you see any pattern in the data?
End of explanation
mov.domestic_gross_rating_plot()
Explanation: Findings
Movies marketed towards adults are on average 10-15% longer than those for younger audiences.
Movies marketed towards younger audiences are far more likely to produce larger domestic gross sales.
Exercise 4
Plot the Domestic Total Gross by the Release Date. Segment by Rating - that is, have all 4 groups on the same plot. Can you spot anything out of the ordinary? Now make 4 separate plots (one for each Rating) but part of the same matplotlib figure. What are the benefits and liabilities of each approach?
End of explanation
directors = mov.director_performance()
print('Top 10 Directors')
directors.head(10)
print('Top 10 Directors with more than one release')
directors.query('qty > 1').head(10)
Explanation: Findings
The combined plot makes details of most of the data difficult to interpret, but highlights the points that are above average.
The segregated plots require the scales to be set equal on each plot to facilitate a comparision.
By combining all these plots together a composite view of the data is formed resulting in insight.
Exercise 5
Who are the top 10 directors with the highest gross per movie (highest average gross)? How many movies did they release in that time period? Who are the top 10 directors with the highest average gross excluding one-hit wonders (directors that have a single release in the dataset)?
End of explanation
mov.domestic_gross_vs_months()
Explanation: Exercise 6
Group the movies by month of release and plot the mean Domestic Total Gross by month. Calculate the Standard Error and add error bars to the plot. Can you tell any pattern from the data?
End of explanation
<END_TASK>