|
22 | 22 | # possible solution maybe here https://docs.python.org/3/library/unittest.mock.html#where-to-patch |
23 | 23 | from example_pkg import foo_func |
24 | 24 | from example_pkg import bar_func |
| 25 | +from dataTransforming import transformationForData |
25 | 26 |
|
| 27 | +from functools import reduce |
| 28 | +import pandas as pd |
| 29 | +import numpy as np |
26 | 30 | # import pipeLine |
27 | 31 |
|
28 | 32 | url = 'http://api.worldbank.org/v2/country/all/indicator/SP.POP.TOTL?format=json' |
@@ -74,6 +78,30 @@ def test_playdata(self): |
74 | 78 | df = pd.DataFrame({'c1': [10, 11, 12], 'c2': [100, 110, 120]}) |
75 | 79 | for index, row in df.iterrows(): |
76 | 80 | print(row['c1'], row['c2']) |
| 81 | + df.applymap |
| 82 | + |
| 83 | + def test_framingApply(self): |
| 84 | + #https://stackoverflow.com/questions/16476924/how-to-iterate-over-rows-in-a-dataframe-in-pandas first version |
| 85 | + # |
| 86 | + df = pd.DataFrame({'c1': [10, 11, 12], 'c2': [100, 110, 120]}) |
| 87 | + for index, row in df.iterrows(): |
| 88 | + print(row['c1'], row['c2']) |
| 89 | + |
| 90 | + df.apply(transformationForData, axis=0, raw=False, result_type=None, args=()) |
| 91 | + #DataFrame.apply(func, axis=0, raw=False, result_type=None, args=(), **kwds) |
| 92 | + #transformingMain("testing") |
| 93 | + bar_func() |
| 94 | + |
| 95 | + def test_sanity1(self): |
| 96 | + result = bar_func() |
| 97 | + result = transformationForData("testing") |
| 98 | + self.assertEqual(result,"testausta") |
| 99 | + |
| 100 | + def test_sanity2(self): |
| 101 | + df = pd.DataFrame([[4, 9]] * 3, columns=['A', 'B']) |
| 102 | + print(df.apply(np.sqrt)) |
| 103 | + print(df) |
| 104 | + |
77 | 105 |
|
78 | 106 | if __name__ == '__main__': |
79 | 107 | unittest.main() |
0 commit comments