Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- def findMaxPrimeNum(array):
- return array[array % 2 == 0].max()
- # Test1
- print(findMaxPrimeNum(np.arange(0, 99, 3)))
- def findZeroPrefixMax(array):
- return array[list(filter(lambda i: array[i + 1] == 0 and array[i] != 0, range(0, array.size - 1)))].max()
- # Test2
- array = np.array([6, 2, 0, 3, 0, 0, 5, 7, 0])
- print(findZeroPrefixMax(array))
- def getSuperDuperRepeatArray(array):
- return np.repeat(array, array)
- # Test3
- print(getSuperDuperRepeatArray(np.array([0, 1, 2, 3, 4, 5])))
- def getPolyderPolynomValueOfX(vector, x):
- return np.polyval(np.polyder(np.poly(vector)), x)
- # Test4
- print(getPolyderPolynomValueOfX(np.array([3, 4, 7]), 1))
- def isEqualSumColumnsAndTables(array):
- return np.all(array.sum(axis=0) == array.sum(axis=1))
- # Test5
- print(isEqualSumColumnsAndTables(np.array([[1, 1], [1, 1]])))
- def getCorrectDataFrame(dataFrame):
- return dataFrame.where(dataFrame != None, 0)
- # Test 6
- print(getCorrectDataFrame(
- pd.read_csv('road_data.csv',
- sep = ',', header = 0, names =
- ['cars', 'accidents', 'vodka', 'crime', 'income', 'retail']
- )))
- def getFilteredDataFrame(dataFrame):
- return dataFrame[
- (dataFrame.accidents > 150) &
- ((dataFrame.vodka > 10) | (dataFrame.crime > 1000))
- ].sort_values('accidents', ascending=0)
- # Test 7
- print(getFilteredDataFrame(pd.read_csv('road_data.csv',
- sep = ',', header = 0, names =
- ['cars', 'accidents', 'vodka', 'crime', 'income', 'retail']
- )))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement