Problem 1: 3 Libraries
Random Library
- When dealing with random guessing games in Python, the random library allows you to generate a random number in a range of numbers and also shuffle a list of numbers to randomize it.
- random.random(0,100)
- random.shuffle(x)
Flask Library
- Flask allows you to create a development server within your project. We are even working with Flask right now in our passion project. Tt allows you to create endpoints with dictionary data that can be read by the frontend and also be expanded to interact with databases.
- @app.route(‘/api/data’)
- return render_template(‘index.html’)
NumPy Library
- NumPy allows you to perform different math functions on arrays. It isn’t allows used on arrays. The mathematical functions that it has is particularly used when working with datasets.
- np.array()
- np.mean()
Problem 2: Spotify API
- Somehing unique that I learned in the documentation is that a lot of the setup to be able to interact with Spotify’s API is just getting authorized and creating you token. A lot of the code looks short when trying to implement some feature of Spotify but the tokens and authorization seem confusing
- Spotify’s API uses REST and returns JSON data
- Spotify’s API that allows you to implement a part of their website into your own. So if you want to display your playlist, favorite artist, or song on your website, you can easily do so by using their API
- One feature that I would use Spotify for is to show y my music taste on my personal blog. When a user wants to know more about you, they can connect with you through music so you can use Spotify’s API to show your user profile, favorite artists, and playlists.
Problem 3: Data Manipulation
Pandas and Matplotlib
- Pandas is used for analyzing and manipulating data. It is a very common tool that is used when people want to deal with data
-
Pandas is also really easy to use when using Jupyter Notebooks
- Matplotlib is used to visualize the data with different types of graphs(bar, scatter, line)
# import pandas library
import pandas as pd
# assign dataframe variable to csv
df = pd.read_csv('../../student2/_notebooks/files/air_quality_no2.csv')
# look at the first 5 values
df.head()
datetime | station_antwerp | station_paris | station_london | |
---|---|---|---|---|
0 | 2019-05-07 02:00:00 | NaN | NaN | 23.0 |
1 | 2019-05-07 03:00:00 | 50.5 | 25.0 | 19.0 |
2 | 2019-05-07 04:00:00 | 45.0 | 27.7 | 19.0 |
3 | 2019-05-07 05:00:00 | NaN | 50.4 | 16.0 |
4 | 2019-05-07 06:00:00 | NaN | 61.9 | NaN |
# Rows 0,3, and 4 all have null values so remove them with dropna
new_df = df.dropna()
# inspect the new dataframe. Since row 1 in the original dataframe had all null values, it doesnt show up in the new one
new_df.head()
datetime | station_antwerp | station_paris | station_london | |
---|---|---|---|---|
1 | 2019-05-07 03:00:00 | 50.5 | 25.0 | 19.0 |
2 | 2019-05-07 04:00:00 | 45.0 | 27.7 | 19.0 |
25 | 2019-05-08 03:00:00 | 23.0 | 19.6 | 20.0 |
26 | 2019-05-08 04:00:00 | 20.5 | 15.3 | 20.0 |
49 | 2019-05-09 03:00:00 | 20.0 | 10.6 | 31.0 |
# import matplotlib library to visualize the data
import matplotlib.pyplot as plt
# graph the new dataframe and show it
new_df.plot()
plt.show()
new_df.plot(kind='hist')
plt.show()