Practice with Pandas, Numpy, Scikit-learn
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2 * np.pi, 200)
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x, y)
plt.show()
Following this guide for python
import pandas as pd # setting pd as alias
mydataset = { # table data
'cars': ["BMW", "Volvo", "Ford"],
'passings': [3, 7, 2]
}
a = [1, 7, 2]
myarray = pd.Series(a)
mytable = pd.DataFrame(mydataset) # assigning dataset as table to be printed
print(myarray)
print(myarray[0]) # indexing
print(mytable)
import pandas as pd # how to print csv file
df = pd.read_csv('data.csv')
print(df)
df = pd.read_json('data.json') # how to read json file
print(df.to_string())
NumPy is a library used to manage arrays
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(arr)
# arrays can have any # of dimensions <= 0
arr = np.array([[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]])
print(arr)
print(arr.ndim) # ndim checks dimensions of array
print(arr[0, 1]) # index order: row then column