Giter VIP home page Giter VIP logo

dsc-chi-warmup-pandas2's Introduction

Pandas Warmup

Pandas out yer ears

Run the cell below w/o changes to load tests

#run without changes

from test_background import pkl_dump, test_obj_dict, run_test_dict, run_test

Data setup

Import:

  • Pandas under the alias 'pd'

  • Matplotlib.pyplot under the alias 'plt'

Run:

  • %matplotlib inline
#Your code here

Make a dataframe by reading in the csv 'Chicago_Park_District__Movies_in_the_Parks_2019' which is in the "data" folder

Assign the dataframe to the variable 'movies'

Look at the first five rows

#Your code here

What kind of type is the data in the Date column? Turn it into a datetime type if it's not already

#Your code here

Replace the truncated days of the week in the Days column with the full string of the day of the week using the Date column

Hint

#Your code here

Sort movies by the Day column, with 'Monday' first and 'Sunday' last

Hint

#Your code here

Data Exploration

What is the most frequent place to show a movie? (Remember that there might be a tie!)

Assign your answer to the variable venue_max as a list of one or more strings

#Your code here
#test your answer here

run_test(venue_max, 'venue_max')

What's the area code in which movies are shown most frequently?

Assign your answer to the variable area_code as an integer

#Your code here
#run this cell to test your answer

run_test(area_code, 'area_code')

Data Manipulation

Group the data by what day of the week the movies are shown using .groupby()

Assign to the variable movies_grp_day

(concept check: what type of object is this?)

Using movies_grp_day, assign to movies_per_day a series where the index is the day of the week and the values are total counts of movies per day

Again using movies_grp_day, assign to unique_movies_per_day a series where the index is the day of the week and the values are unique counts of movies per day of the week.

Use movies_per_day and unique_movies_per_day to calculate a series of how many movie showings per day of the week are of movies that are shown more than once. Assign this series to repeats

Sort repeats so Monday is the first entry and Sunday is the last

#Your code here
#test your answer here

run_test(repeats, 'repeats')

Which day of the week has the fewest underwriters? Run a calculation that results in a string (ie, don't run a calculation which displays the answer somewhere and then create a new string with the answer)

Assign that string to day_underwriter_min

#Your code here
#test your answer here

run_test(day_underwriter_min, 'day_underwriter_min')

Using movies_grp_day, assign the variable model_ratings_day to a series where the index is the days of the week and the values are the modal rating for movies shown that day

Sort so that the first index is Monday and the last is Sunday

Hint: look at the groupby documentation and write a function

#Your code here
#test your answer here
run_test(modal_ratings_day, 'modal_ratings_day')

Strrretch Goal

Make a stacked bar chart showing the ratings of movies across days of the week using fig and ax objects

Title the x-axis "Day"

Title the y-axis "Count of Movies Shown"

Title the chart as a whole "Chicago Movies in the Park by Day and Rating"

Hint

When you're done it should look like this (w/ figsize 8,5):

#Your code here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.