Skip to content

Commit c84b7da

Browse files
committed
2 parents 0f522a4 + 4d926be commit c84b7da

3 files changed

Lines changed: 111 additions & 0 deletions

File tree

test/test_last_columndf.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
3+
from toolkit.data_processing import last_columndf, uniq_value,list_categorical_columns
4+
from toolkit.data_analysis import *
5+
from toolkit.machine_learning import *
6+
from toolkit.plot import *
7+
8+
import pandas as pd
9+
import numpy as pd
10+
import pytest
11+
12+
13+
@pytest.fixture
14+
15+
16+
def test_data():
17+
18+
df = pd.DataFrame({'a':['1','2','3','4'],
19+
'b': [16,7,6,16],
20+
'c':[61,57,16,36],
21+
'd':['12','22','13','44'],
22+
'e':['Green','Red','Blue','Yellow'],
23+
'f':[1,11,23,66]})
24+
list_features=df.columns.to_list()
25+
feature=list_features[0]
26+
return df,feature
27+
28+
29+
def test_last_columndf(test_data):
30+
df,feature=test_data()
31+
df=last_columndf(df,feature)
32+
list_features=df.columns.to_list()
33+
feature=list_features[-1]
34+
35+
assert feature == 'a'
36+
37+
38+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
3+
from toolkit.data_processing import last_columndf, uniq_value,list_categorical_columns
4+
from toolkit.data_analysis import *
5+
from toolkit.machine_learning import *
6+
from toolkit.plot import *
7+
8+
import pandas as pd
9+
import numpy as pd
10+
import pytest
11+
12+
13+
@pytest.fixture
14+
15+
16+
def test_data():
17+
18+
df = pd.DataFrame({'a':['1','2','3','4'],
19+
'b': [16,7,6,16],
20+
'c':[61,57,16,36],
21+
'd':['12','22','13','44'],
22+
'e':['Green','Red','Blue','Yellow'],
23+
'f':[1,11,23,66]})
24+
list_features=df.columns.to_list()
25+
feature=list_features[0]
26+
return df,feature
27+
28+
29+
30+
def test_list_categorical_columns(test_data):
31+
df,feature=test_data()
32+
r=list_categorical_columns(df)
33+
34+
35+
assert r== ['e']
36+
37+

test/test_uniq_value.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
3+
from toolkit.data_processing import last_columndf, uniq_value,list_categorical_columns
4+
from toolkit.data_analysis import *
5+
from toolkit.machine_learning import *
6+
from toolkit.plot import *
7+
8+
import pandas as pd
9+
import numpy as pd
10+
import pytest
11+
12+
13+
@pytest.fixture
14+
15+
16+
def test_data():
17+
18+
df = pd.DataFrame({'a':['1','2','3','4'],
19+
'b': [16,7,6,16],
20+
'c':[61,57,16,36],
21+
'd':['12','22','13','44'],
22+
'e':['Green','Red','Blue','Yellow'],
23+
'f':[1,11,23,66]})
24+
list_features=df.columns.to_list()
25+
feature=list_features[0]
26+
return df,feature
27+
28+
def test_uniq_value(test_data):
29+
df,feature=test_data()
30+
df_list=df['b'].tolist()
31+
r=uniq_value(df_list)
32+
33+
assert len(r)== '3'
34+
35+
36+

0 commit comments

Comments
 (0)