<jupyter_start><jupyter_text>Pie Charts**Teammates: <NAME>, <NAME>, <NAME>** What is a pie chart?A pie chart is a type of graph in which a circle is divided into sectors that each represent a proportion of the whole.  **Think about it...****When you come across text in green take some time to write an answer to the questions before reading on!** Where have you seen pie charts used in the past? Mostly in memes, also to keep track of where expenses go ______  What are pie charts used for? - Pie charts represent data as part of a whole set- Pie charts show percentages - the entire circle represents 100%- Pie charts are best when one has 2 - 5 data points that are significantly different What is an example of data that would be well represented with a pie chart? Monthly spending categories ______  What are mistakes people make with pie charts?**BEWARE: Pie charts are controversial! Some people don't like pie charts because they can be challenging to read and understand if not thoughtfully made. Here are some challenges and mistakes regarding pie charts.**- Pie  charts communicate percentage of a whole but don't always well-represent magnitude of data- Not organizing pie chart slices from largest to smallest in one direction- Using too many slices     - rule of thumb: don't use a pie chart with more than 5 slices- Using 3D pie charts    - these are confusing and don't help represent data any better than a 2D pie chart- Making multiple pie charts to compare to each other    - comparing pie charts is overwhelming and not visually appealing     Run the following code to make two basic pie charts. Which pie chart is easier to read? Why?<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data1 = np.array([5, 12, 17, 20])
data2 = np.array([1, 1, 1, 4, 5, 7, 8, 12, 15, 16, 22, 23, 24])
plt.pie(data1)
plt.show()
plt.pie(data2)
plt.show()<jupyter_output><empty_output><jupyter_text>Which pie chart is easier to visually comprehend? Why do you think so?   _______ The first pie chart since there are not nearly as many slices to consider  What do pie charts look like in Python?Run the following code to see what a pie chart looks like in Python<jupyter_code>colors_data = [10, 23, 35]
df = pd.DataFrame(colors_data, index=['Red', 'Yellow', 'Blue'], columns=['Num Votes'])
df.plot.pie(y='Num Votes', colors=['red', 'yellow', 'cornflowerblue'], figsize=(5, 5), title="Favorite Colors of Class of 2021", legend=False, autopct='%1.1f%%', fontsize=15)
plt.show()<jupyter_output><empty_output><jupyter_text>____  What code do we use to generate pie charts?Let's unpack the code from above and expand on it. First: create a list named `colors_data` that represent the number of votes per color. ``` pythoncolors_data = [10, 23, 35]```Second: create a Pandas DataFrame passing in `colors_data` as the data, naming the index (rows) 'Red', 'Yellow', and 'Blue' to represent the color of each row, and naming the column 'Num Votes'.``` pythondf = pd.DataFrame(colors_data, index=['Red', 'Yellow', 'Blue'], columns=['Num Votes'])```Finally, call `df.plot.pie()` to draw the graph. Let's unpack each parameter. `y` is the column or label of the data in the DataFrame to be plotted in the pie chart. `colors` represents which color each row's slice will be in the chart.`figsize` indicates the size of the plot in inches `(width, height)``title` is the title of the graph. Make sure it's descriptive and matches the data!`legend` is set to False. If set to True, a legend will be created. It was not necessary in this instance because the label of each slice is descriptive. `autopct` displays each slice's percentage using Python string formatting. `fontsize` indicates the size of the font on the graph.``` pythondf.plot.pie(y='Num Votes', colors=['red', 'yellow', 'cornflowerblue'], figsize=(5,5), title="Favorite Colors of Class of 2021", legend=False, autopct='%1.1f%%', fontsize=15)``` QuestionProvided is a list of number of votes. The votes represent the answer to a poll: Which weekend day is better, Saturday or Sunday? Make a Pandas DataFrame representing this data and plot it as a pie chart. Make Saturday's slice green and Sunday's slice orange.<jupyter_code># list of votes
weekend_votes = [100, 133]
votes = pd.DataFrame(weekend_votes, index=['Saturday', 'Sunday'], columns=['Days'])
votes.plot.pie(y="Days", colors=['green', 'orange'], legend=False, title="Which day is better?", autopct="%1.1f%%")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09347874471399956, 'fraction_numerical': 0.01736033830402849, 'mean_word_length': 5.008021390374331, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '36867', 'license': 'MIT', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1223, 'n_words': 648, 'path': 'VisualizationLessons/pie_charts.ipynb', 'repo_name': 'copl68/367FirstAssignment', 'size': '4518'}