def testSingleValDictDataFrameCorrReturnSerie(self): stockData = {"Blackstone": [49.56] } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.countDF(df) expected = pd.DataFrame(stockData).corr()
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 testEmptyTailDFReturnsTailDataFame(self): stocksData ={ } npsy = NumpySciPy() df = npsy.initDataFrame(stocksData) actual = npsy.tailDF(df) expected = pd.DataFrame(stocksData).tail()
def testEmptyDataFrameCorrReturnEmptySeries(self): stockData = { } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.countDF(df) expected = pd.DataFrame(stockData).corr()
def testappendDFReturnsEmptyDataFame(self): stocksData = { } npsy = NumpySciPy() df = npsy.initDataFrame(stocksData) actual = npsy.appendDF(dataframe=df,appendDataFrame=df) expected = pd.DataFrame(df).append(df)
def testEmptyHeadDFReturnsHeadDataFame(self): stocksData ={ } npsy = NumpySciPy() df = npsy.initDataFrame(stocksData) actual = npsy.headDF(df) expected = pd.DataFrame(stocksData).head()
def testaverageDFReturnsEmptySeriesMean(self): stockData ={ } npsy = NumpySciPy() df = npsy.initDataFrame(stockData) actual = npsy.averageDF(df) expected = pd.DataFrame(stockData).mean()
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 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 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 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 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 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 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 testEmptyDataInitDataFrameReturnsDataFame(self): stocksData ={ } npsy = NumpySciPy() actual = npsy.initDataFrame(stocksData) expected = pd.DataFrame(stocksData)