Lesson Portion 6 Hacks

Printing a CSV File (0.5)

  • Use this link https://github.com/ali-ce/datasets to select csv file of a topic you are interested in, or you may find one online.
  • Once you select your topic make sure it is a csv file and then you want to press on the button that says raw.
  • After that copy that information and create a file with a name and .csv at the end and paste your information.
  • Below is a start that you can use for your hacks.
  • Your goal is to print 2 specific parts from data (example could be like population and country).
import pandas as pd
# Load the CSV file into a Pandas DataFrame
df = pd.read_csv('/home/zeen/vscode/zeeeeen/_notebooks/AI.csv')
# Filter the DataFrame to only include stats for a  (in this case, Jimmy Butler)
Project_name = 'Google Now'
Project_stats = df[df['Project'] == Project_name]
# Print out the column names of the DataFrame
# print(df.columns)

# Display the stats of locaiton and year for the Project
print(f"\nStats for {Project_name}:")
print(Project_stats[['Location', 'Year']])
Stats for Google Now:
        Location  Year
2  United States  2012

Popcorn Hacks (0.2)

import numpy as np

#Create a NumPy array of the Weights, Weights is the weight.
Weights = np.array([50,60,70,65,64,55,58,60,50])

# Calculate the percentile rank of Weights
percentiles = np.percentile(Weights, [25,60,80])

# Print the results
print("The 25th percentile weight is", percentiles[0], "kg")
print("The 60th percentile weight is", percentiles[1], "kg")
print("The 80th percentile weight is", percentiles[2], "kg")

# Determine the number of players who are in the top 10% Weights
top_10_percent = np.percentile(Weights, 90)
z = Weights[Weights >= top_10_percent]

print("There are", len(z), "players in the top 10% heavest.")
The 25th percentile weight is 55.0 kg
The 60th percentile weight is 60.0 kg
The 80th percentile weight is 64.4 kg
There are 1 players in the top 10% heavest.

Answering Questions (0.2)

Question Hacks

What is NumPy and how is it used in data analysis?

  • Numpy can process numerical values, put data together, so they are very important

What is Pandas and how is it used in data analysis?

  • Pandas can mark the position of each numerical value, it involves data analysis in python.

How is NunPy different than Pandas for data analysis?

  • Numpy is to put datas together and pandas is to mark each data to help you find the specific one.

What is a DataFrame?

  • It can label data structure with columns.

What are some common operations you can perform with NunPy?

  • It can work with arrays and apply some mathematics funciton.

How Can You Incorporate Either of these Data Analysis Tools (NunPy, Pandas) into your project?

  • I think I can import numpy to array my data in my database and using pandas to find the specific user with their id and scores, or do some stats to find mean, median and so on.

Submit By Thursday 8:35 A.M.

  • How to Submit: Slack a Blog Post that includes all of your hacks to "Joshua Williams" on Slack.