This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| from scipy.stats import linregress | |
| import numpy as np | |
| def draw_plot(): | |
| # Import data | |
| df = pd.read_csv("epa-sea-level.csv") | |
| # Create scatter plot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| # Import data | |
| df = pd.read_csv("fcc-forum-pageviews.csv", parse_dates=['date'], index_col='date') | |
| # Clean data (remove top 2.5% and bottom 2.5%) | |
| df = df[ | |
| (df['value'] >= df['value'].quantile(0.025)) & |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import seaborn as sns | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| def draw_heat_map(): | |
| # Load data | |
| df = pd.read_csv('medical_examination.csv') | |
| # Clean the data |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| def calculate_demographic_data(print_data=True): | |
| # Read data | |
| df = pd.read_csv("adult.data.csv") | |
| # 1. Count of each race | |
| race_count = df['race'].value_counts() | |
| # 2. Average age of men |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def calculate(lst): | |
| # Check if list contains exactly 9 elements | |
| if len(lst) != 9: | |
| raise ValueError("List must contain nine numbers.") | |
| # Convert list into 3x3 NumPy array | |
| matrix = np.array(lst).reshape(3, 3) | |