Skip to content

Commit 5c7784a

Browse files
committed
Update tests
1 parent 73e8e1b commit 5c7784a

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

databricks/koalas/tests/test_dataframe.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -1059,9 +1059,10 @@ def test_pivot_table(self):
10591059
# Todo: self.assert_eq(kdf.pivot_table(index=['c'], columns="a", values="b"),
10601060
# pdf.pivot_table(index=['c'], columns=["a"], values="b"))
10611061

1062-
# Todo: self.assert_eq(kdf.pivot_table(index=['c'], columns="a", values=['b', 'e'],
1063-
# aggfunc={'b': 'mean', 'e': 'sum'}), pdf.pivot_table(index=['c'], columns=["a"],
1064-
# values=['b', 'e'], aggfunc={'b': 'mean', 'e': 'sum'}))
1062+
self.assert_eq(kdf.pivot_table(index=['c'], columns="a", values=['b', 'e'],
1063+
aggfunc={'b': 'mean', 'e': 'sum'}).to_pandas().sort_index(),
1064+
pdf.pivot_table(index=['c'], columns=["a"],
1065+
values=['b', 'e'], aggfunc={'b': 'mean', 'e': 'sum'}))
10651066

10661067
# Todo: self.assert_eq(kdf.pivot_table(index=['e', 'c'], columns="a", values="b"),
10671068
# pdf.pivot_table(index=['e', 'c'], columns="a", values="b"))
@@ -1089,19 +1090,19 @@ def test_pivot_table_errors(self):
10891090

10901091
kdf = ks.from_pandas(pdf)
10911092

1092-
msg = "values should be string or list of one column."
1093+
msg = "Values should be string or list of one column."
10931094
with self.assertRaisesRegex(ValueError, msg):
10941095
kdf.pivot_table(index=['c'], columns="a", values=5)
10951096

1096-
msg = "index should be a None or a list of columns."
1097+
msg = "Index should be a None or a list of columns."
10971098
with self.assertRaisesRegex(ValueError, msg):
10981099
kdf.pivot_table(index="c", columns="a", values="b")
10991100

1100-
msg = "pivot_table doesn't support aggfunc as dict and without index."
1101+
msg = "Pivot_table doesn't support aggfunc as dict and without index."
11011102
with self.assertRaisesRegex(NotImplementedError, msg):
11021103
kdf.pivot_table(columns="a", values=['b', 'e'], aggfunc={'b': 'mean', 'e': 'sum'})
11031104

1104-
msg = "columns should be string."
1105+
msg = "Columns should be string."
11051106
with self.assertRaisesRegex(ValueError, msg):
11061107
kdf.pivot_table(columns=["a"], values=['b'], aggfunc={'b': 'mean', 'e': 'sum'})
11071108

@@ -1110,9 +1111,18 @@ def test_pivot_table_errors(self):
11101111
kdf.pivot_table(index=['e', 'c'], columns="a", values='b',
11111112
aggfunc={'b': 'mean', 'e': 'sum'})
11121113

1113-
msg = 'Values as list of columns is not implemented yet.'
1114+
msg = "Values can't be a list without index."
11141115
with self.assertRaisesRegex(NotImplementedError, msg):
1115-
kdf.pivot_table(index=['c'], columns="a", values=['b', 'e'],
1116+
kdf.pivot_table(columns="a", values=['b', 'e'])
1117+
1118+
msg = "Values more than two is not supported yet!"
1119+
with self.assertRaisesRegex(NotImplementedError, msg):
1120+
kdf.pivot_table(index=['e'], columns="a", values=['b', 'e', 'c'],
1121+
aggfunc={'b': 'mean', 'e': 'sum', 'c': 'sum'})
1122+
1123+
msg = "Wrong columns A."
1124+
with self.assertRaisesRegex(ValueError, msg):
1125+
kdf.pivot_table(index=['c'], columns="A", values=['b', 'e'],
11161126
aggfunc={'b': 'mean', 'e': 'sum'})
11171127

11181128
def test_transpose(self):

0 commit comments

Comments
 (0)