Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Task 1.3.1
- import numpy as np
- checkboard_array = np.zeros((8, 8), dtype=int)
- checkboard_array[1::2, ::2] = 1
- checkboard_array[::2, 1::2] = 1
- print(checkboard_array)
- Task 1.3.2
- import numpy as np
- x = np.zeros((5,5))
- x += np.arange(5)
- print(x)
- Task 1.3.3
- import numpy as np
- x = np.random.random((3,3,3))
- print(x)
- Task 1.3.4
- import numpy as np
- x = np.ones((5,5))
- x[1:-1, 1:-1] = 0
- print(x)
- Task 1.3.5
- import numpy as np
- x = np.random.randint(1,20, 10)
- print(x)
- x[::-1].sort()
- print(x)
- Task 1.3.6
- import numpy as np
- matrix = np.array([np.random.randint(1,10, 5) for _ in range(4)])
- print(matrix)
- print(f'Matrix shape is: {matrix.shape}',
- f'Matrix ndim is: {matrix.ndim}',
- f'Matrix size is: {matrix.size}', sep='\n')
- Task 2.3.1
- import pandas as pd
- ser_1 = pd.Series([1,3,6,9])
- ser_2 = pd.Series([2,5,7,10])
- print(sum((ser_1-ser_2)**2)**.5)
- Task 2.3.2
- import pandas as pd
- url = r'https://raw.githubusercontent.com/akmand/datasets/main/airlines.csv'
- dataframe = pd.read_csv(url)
- print(dataframe.head(10))
- Task 2.3.3 <-- продолжение 2.3.2
- print(dataframe.tail(3))
- print(dataframe.shape)
- print(dataframe.describe())
- print(dataframe.iloc[2:6])
- print(dataframe[dataframe['Airline'] == 'US'].head(2))
- #Task 3.3.2
- import pandas as pd
- from sklearn.preprocessing import MinMaxScaler, StandartScaler
- url = r'https://raw.githubusercontent.com/akmand/datasets/master/iris.csv'
- dataframe = pd.read_csv(url)
- scaler = MinMaxScaler()
- std_scaler = StandartScaler()
- sepal_length = min_max_scaler.fit_transform(dataframe['sepal_length_cm'].values.reshape(-1, 1))
- sepal_width = std_scaler.fit_transform(dataframe['sepal_width_cm'].values.reshape(-1, 1))
- print(sepal_width)
- print(sepal_length)
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement