starting DataFrameFilterTest
This commit is contained in:
9
src/SymptomsCausedByVaccines/DataFrameFilter.py
Normal file
9
src/SymptomsCausedByVaccines/DataFrameFilter.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class DataFrameFilter:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def withoutZeroRows(dataFrame):
|
||||||
|
return dataFrame.loc[~DataFrameFilter._isZeroRow(dataFrame)]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _isZeroRow(dataFrame):
|
||||||
|
return (dataFrame == 0.0).all(axis = 'columns')
|
||||||
54
src/SymptomsCausedByVaccines/DataFrameFilterTest.py
Normal file
54
src/SymptomsCausedByVaccines/DataFrameFilterTest.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import unittest
|
||||||
|
from pandas.testing import assert_frame_equal
|
||||||
|
from TestHelper import TestHelper
|
||||||
|
import pandas as pd
|
||||||
|
from SymptomsCausedByVaccines.DataFrameFilter import DataFrameFilter
|
||||||
|
|
||||||
|
class DataFrameFilterTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_withoutZeroRows_noZeroRow(self):
|
||||||
|
# Given
|
||||||
|
dataFrame = TestHelper.createDataFrame(
|
||||||
|
columns = ['col1', 'col2'],
|
||||||
|
data = [ [0.6, 1.5],
|
||||||
|
[0.3, 3.0]],
|
||||||
|
index = pd.Index(
|
||||||
|
name = 'VAX_TYPE',
|
||||||
|
data = [
|
||||||
|
'6VAX-F',
|
||||||
|
'ADEN'
|
||||||
|
]))
|
||||||
|
|
||||||
|
# When
|
||||||
|
dataFrameWithoutZeroRows = DataFrameFilter.withoutZeroRows(dataFrame)
|
||||||
|
|
||||||
|
# Then
|
||||||
|
assert_frame_equal(dataFrameWithoutZeroRows, dataFrame)
|
||||||
|
|
||||||
|
def test_withoutZeroRows(self):
|
||||||
|
# Given
|
||||||
|
dataFrame = TestHelper.createDataFrame(
|
||||||
|
columns = ['col1', 'col2'],
|
||||||
|
data = [ [0.6, 1.5],
|
||||||
|
[0.0, 0.0]],
|
||||||
|
index = pd.Index(
|
||||||
|
name = 'VAX_TYPE',
|
||||||
|
data = [
|
||||||
|
'6VAX-F',
|
||||||
|
'ZERO ROW'
|
||||||
|
]))
|
||||||
|
|
||||||
|
# When
|
||||||
|
dataFrameWithoutZeroRows = DataFrameFilter.withoutZeroRows(dataFrame)
|
||||||
|
|
||||||
|
# Then
|
||||||
|
assert_frame_equal(
|
||||||
|
dataFrameWithoutZeroRows,
|
||||||
|
TestHelper.createDataFrame(
|
||||||
|
columns = ['col1', 'col2'],
|
||||||
|
data = [ [0.6, 1.5]],
|
||||||
|
index = pd.Index(
|
||||||
|
name = 'VAX_TYPE',
|
||||||
|
data = [
|
||||||
|
'6VAX-F'
|
||||||
|
])))
|
||||||
File diff suppressed because one or more lines are too long
100
src/data/tfiltered.csv
Normal file
100
src/data/tfiltered.csv
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user