| Conditions | 1 |
| Total Lines | 53 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import numpy as np |
||
| 27 | def test_drop_missing(self): |
||
| 28 | self.assertEqual(drop_missing(self.df_data_drop).shape, (4, 4)) |
||
| 29 | |||
| 30 | # Drop further columns based on threshold |
||
| 31 | self.assertEqual( |
||
| 32 | drop_missing(self.df_data_drop, drop_threshold_cols=0.5).shape, (4, 3) |
||
| 33 | ) |
||
| 34 | self.assertEqual( |
||
| 35 | drop_missing( |
||
| 36 | self.df_data_drop, drop_threshold_cols=0.5, col_exclude=["c1"] |
||
| 37 | ).shape, |
||
| 38 | (4, 4), |
||
| 39 | ) |
||
| 40 | self.assertEqual( |
||
| 41 | drop_missing(self.df_data_drop, drop_threshold_cols=0.49).shape, (4, 2) |
||
| 42 | ) |
||
| 43 | self.assertEqual( |
||
| 44 | drop_missing(self.df_data_drop, drop_threshold_cols=0).shape, (0, 0) |
||
| 45 | ) |
||
| 46 | |||
| 47 | # Drop further rows based on threshold |
||
| 48 | self.assertEqual( |
||
| 49 | drop_missing(self.df_data_drop, drop_threshold_rows=0.67).shape, (4, 4) |
||
| 50 | ) |
||
| 51 | self.assertEqual( |
||
| 52 | drop_missing(self.df_data_drop, drop_threshold_rows=0.5).shape, (4, 4) |
||
| 53 | ) |
||
| 54 | self.assertEqual( |
||
| 55 | drop_missing(self.df_data_drop, drop_threshold_rows=0.49).shape, (3, 4) |
||
| 56 | ) |
||
| 57 | self.assertEqual( |
||
| 58 | drop_missing(self.df_data_drop, drop_threshold_rows=0.25).shape, (3, 4) |
||
| 59 | ) |
||
| 60 | self.assertEqual( |
||
| 61 | drop_missing(self.df_data_drop, drop_threshold_rows=0.24).shape, (2, 4) |
||
| 62 | ) |
||
| 63 | self.assertEqual( |
||
| 64 | drop_missing( |
||
| 65 | self.df_data_drop, drop_threshold_rows=0.24, col_exclude=["c1"] |
||
| 66 | ).shape, |
||
| 67 | (2, 5), |
||
| 68 | ) |
||
| 69 | self.assertEqual( |
||
| 70 | drop_missing( |
||
| 71 | self.df_data_drop, drop_threshold_rows=0.24, col_exclude=["c2"] |
||
| 72 | ).shape, |
||
| 73 | (2, 4), |
||
| 74 | ) |
||
| 75 | self.assertEqual( |
||
| 76 | drop_missing( |
||
| 77 | self.df_data_drop, drop_threshold_rows=0.51, col_exclude=["c1"] |
||
| 78 | ).shape, |
||
| 79 | (3, 5), |
||
| 80 | ) |
||
| 209 |