2.3 Hacks
week 25 hacks
AP Prep/Notes
College Board talks about ideas like
- Tools.
"the ability to process data depends on users capabilities and their tools"
- Combining Data.
"combine county data sets"
- Status on Data
"determining the artist with the greatest attendance during a particular month"
- Data poses challenge.
"the need to clean data", "incomplete data"
Pandas and Data Frame
import pandas as pd
df = pd.read_csv('nba.csv')
print(df)
import pandas as pd
df = pd.read_csv('nba.csv')
df2 = df.drop(['FT%', '2PA', '2P%', '3PA', '3P%', 'eFG%', 'TS%', 'PPG', 'RPG', 'APG', 'SPG', 'BPG', 'TPG', 'P+R', 'P+A', 'P+R+A', 'VI', 'ORtg', 'DRtg'], axis=1)
print(df2)
import pandas as pd
#read csv and sort 'Duration' largest to smallest
df3 = df2.sort_values(by=['AGE'], ascending=False)
print("\n"+"--Oldest Top 10---------" + "\n")
print(df3.head(10))
print("\n"+ "--Youngest Bottom 10------" + "\n")
print(df3.tail(10))
print(df2.info())
import pandas as pd
#the data can be stored as a python dictionary
dict = {
"Safin": [16, 7132006, 1],
"Johnny": [16, 6222006, 1]
}
#stores the data in a data frame
print("-------------Dict_to_DF------------------")
df = pd.DataFrame(dict)
print(df)
print("----------Dict_to_DF_labels--------------")
#or with the index argument, you can label rows.
df = pd.DataFrame(dict, index = ["age", "bday", "siblings"])
print(df)
print(df.info())