def testDictDataFrameCorrReturnSerie(self): stockData = {"Blackstone": [49.56, 50.70, 51.18, 52.80, 52.87] } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.countDF(df) expected = pd.DataFrame(stockData).corr()
def testSingleValDictDataFrameCorrReturnSerie(self): stockData = {"Blackstone": [49.56] } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.countDF(df) expected = pd.DataFrame(stockData).corr()
def testaverageDFReturnsEmptySeriesMean(self): stockData ={ } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.averageDF(df) expected = pd.DataFrame(stockData).mean()
def testappendDFReturnsEmptyDataFame(self): stocksData = { } npsy = NumpySciPy() df = npsy.initDataFrame(stocksData) actual = npsy.appendDF(dataframe=df,appendDataFrame=df) expected = pd.DataFrame(df).append(df)
def testEmptyTailDFReturnsTailDataFame(self): stocksData ={ } npsy = NumpySciPy() df = npsy.initDataFrame(stocksData) actual = npsy.tailDF(df) expected = pd.DataFrame(stocksData).tail()
def testEmptyHeadDFReturnsHeadDataFame(self): stocksData ={ } npsy = NumpySciPy() df = npsy.initDataFrame(stocksData) actual = npsy.headDF(df) expected = pd.DataFrame(stocksData).head()
def testEmptyDataFrameCorrReturnEmptySeries(self): stockData = { } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.countDF(df) expected = pd.DataFrame(stockData).corr()
def testDualArrayDictDataFrameCorrReturnSeries(self): stockData = {"Blackstone": [49.56, 50.70, 51.18, 52.80, 52.87], "KKR": [24.24, 24.60, 26.04, 26.90, 26.66] } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.countDF(df) expected = pd.DataFrame(stockData).corr()
def testaverageDFReturnsSeriesMean(self): stockData ={ "Blackstone": [49.56, 50.70, 51.18, 52.80, 52.87, 24.24, 24.60, 49.56, 26.90, 26.66] } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.averageDF(df) expected = pd.DataFrame(stockData).mean()
def testdropDuplicateDFReturnsEmptyDataFame(self): stocksData = { } npsy = NumpySciPy() df = npsy.initDataFrame(stocksData) df = npsy.appendDF(dataframe=df,appendDataFrame=df) actual = npsy.dropDuplicatesDF(df) expected = pd.DataFrame(stocksData).append(df).drop_duplicates()
def testNotFilterColumnDFForCompanyBlackstone(self): stockData = { 'Company': ["BlackStone","KKR","Chase","Bank Of America","Wells Fargo","Morgan Stanley"], "Closing Price":[56.26,21.60,100.21,26.75,84.61,246.25], "LocationHQ": ["New York City,NY","New York City,NY","New York City,NY","Charlotte, NC", "San Francisco, CA","New York City,NY"] } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.notFilterColumnDF(df,"Company","BlackStone")
def testdropDuplicateReturnsDataFame(self): stockData = { "Blackstone": [49.56, 50.70, 51.18, 52.80, 52.87, 24.24, 24.60, 49.56, 26.90, 26.66] } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) df = npsy.appendDF(dataframe=df,appendDataFrame=df) actual = npsy.dropDuplicatesDF(df) expected = pd.DataFrame(stockData).append(df).drop_duplicates()
def testappendDFReturnsDataFame(self): stocksData = { "Blackstone": [49.56, 50.70, 51.18, 52.80, 52.87, 24.24, 24.60, 26.04, 26.90, 26.66], "KKR": [24.24, 24.60, 26.04, 26.90, 26.66, 24.24, 24.60, 26.04, 26.90, 26.66] } npsy = NumpySciPy() df = npsy.initDataFrame(stocksData) actual = npsy.appendDF(dataframe=df,appendDataFrame=df) expected = pd.DataFrame(stocksData).append(df)
def testInitDataFrameReturnsDataFameWithDates(self): stocksData ={ "Blackstone":[49.56,50.70,51.18,52.80,52.87], "KKR": [24.24,24.60,26.04,26.90,26.66] } dates = ['5/4/20','5/5/20','5/6/20','5/8/20','5/9/20'] npsy = NumpySciPy() actual = npsy.initDataFrame(stocksData,rows=dates) expected = pd.DataFrame(stocksData,index=dates)
def testDefaul10TailDFReturnsTailDataFame(self): stocksData = { "Blackstone": [49.56, 50.70, 51.18, 52.80, 52.87,24.24, 24.60, 26.04, 26.90, 26.66], "KKR": [24.24, 24.60, 26.04, 26.90, 26.66,24.24, 24.60, 26.04, 26.90, 26.66] } dates = ['5/4/20', '5/5/20', '5/6/20', '5/8/20', '5/9/20','5/4/20', '5/5/20', '5/6/20', '5/8/20', '5/9/20'] npsy = NumpySciPy() df = npsy.initDataFrame(stocksData, rows=dates) actual = npsy.tailDF(df,) expected = pd.DataFrame(stocksData, index=dates).tail(10)
def testInitDataFrameReturnsDataFame(self): stocksData ={ "Blackstone":[49.56,50.70,51.18,52.80,52.87], "KKR": [24.24,24.60,26.04,26.90,26.66] } npsy = NumpySciPy() actual = npsy.initDataFrame(stocksData) print(actual) expected = pd.DataFrame(stocksData) print(expected)
def testFilterColumnDFAdvForCompanyEmptyDF(self): stockData = { } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) try: actual = npsy.filterColumnDFAdv(df, "Company", "BlackStone") print(actual) except(KeyError): print("Key Doesn't Exist")
def testFilterColumnDFAdvForNotEqualsClosingPrice(self): stockData = { 'Company': ["BlackStone", "KKR", "Chase", "Bank Of America", "Wells Fargo", "Morgan Stanley"], "Closing Price": [56.26, 21.60, 100.21, 26.75, 84.61, 246.25], "LocationHQ": ["New York City,NY", "New York City,NY", "New York City,NY", "Charlotte, NC", "San Francisco, CA", "New York City,NY"] } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.filterColumnDFAdv(df, "Closing Price", 100.21,filterType="NOT_EQUALS") print(actual)
def test_emptyArrayNumpyArray_returns_array(self): npsp = NumpySciPy() arrays = [] actual = npsp.numpyArray(arrays) expected = np.array(arrays) boolArray= actual == expected isTrue =None if False in boolArray: isTrue = False else: isTrue = True self.assertTrue(isTrue)
def testNotFilterColumnDFForOpenPricePrice1226(self): stockData = { 'Company': ["BlackStone", "KKR", "Chase", "Bank Of America", "Wells Fargo", "Morgan Stanley"], "Closing Price": [56.26, 21.60, 100.21, 56.26, 84.61, 246.25], "LocationHQ": ["New York City,NY", "New York City,NY", "New York City,NY", "Charlotte, NC", "San Francisco, CA", "New York City,NY"] } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) try: actual = npsy.notFilterColumnDF(df, "Opening Price", 12.26) except(KeyError): print("Key Doesn't Exist")
def testNumpyAverageMixTypesValueArray(self): npsy = NumpySciPy() multiArray = [[0.01,1],[0.01,1]] actual = npsy.numpyAverage(multiArray) expected = 0.505 self.assertEqual(expected,actual)
def testNumpyAverageOneValueArray(self): npsy = NumpySciPy() multiArray = [[1,2],[1,2]] actual = npsy.numpyAverage(multiArray) expected = 1.5 self.assertEqual(expected,actual)
def testNumpyAveragetwoValueArray(self): npsy = NumpySciPy() emptyArray = [[1,2]] actual = npsy.numpyAverage(emptyArray) expected = 1.5 self.assertEqual(expected,actual)
def testNumpyAverageEmptyArray(self): npsy = NumpySciPy() emptyArray = [] isNaN = np.isnan(npsy.numpyAverage(emptyArray)) self.assertTrue(isNaN)
def testNumpySizeArray3_returns_size1(self): npsy = NumpySciPy() emptyArray = [[1],[2],[3]] actual = npsy.numpySize(emptyArray) expected = 3 self.assertEqual(expected, actual)
def testNumpySizeEmptyArray_returns_size0(self): npsy = NumpySciPy() emptyArray = [] actual = npsy.numpySize(emptyArray) expected = 0 self.assertEqual(expected,actual)
def testArrayInitSeriesreturnSeries(self): priceArray = [49.56, 50.70, 51.18, 52.80, 52.87] npsy = NumpySciPy() actual = npsy.initSeries(priceArray) expected = pd.Index(priceArray)
def test2DArrayInitSeriesreturnObjectSeries(self): priceArray = [[49.56, 50.70, 51.18, 52.80, 52.87],[24.24, 24.60, 26.04, 26.90, 26.66]] npsy = NumpySciPy() actual = npsy.initSeries(priceArray) expected = pd.Index(priceArray)
def testSingleValueArrayValueCountSeriesreturnSerie(self): priceArray = [52.80] npsy = NumpySciPy() series = npsy.initSeries(priceArray) actual = npsy.valueCountSeries(series) expected = pd.Index(priceArray).value_counts()
def testArrayvalueCountSeriesreturnEmptySeries(self): priceArray = [52.80, 52.80, 51.18, 52.80,51.18,52.87] npsy = NumpySciPy() series = npsy.initSeries(priceArray) actual = npsy.valueCountSeries(series) expected = pd.Index(priceArray).value_counts()