@@ -1059,9 +1059,10 @@ def test_pivot_table(self):
1059
1059
# Todo: self.assert_eq(kdf.pivot_table(index=['c'], columns="a", values="b"),
1060
1060
# pdf.pivot_table(index=['c'], columns=["a"], values="b"))
1061
1061
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' }))
1065
1066
1066
1067
# Todo: self.assert_eq(kdf.pivot_table(index=['e', 'c'], columns="a", values="b"),
1067
1068
# pdf.pivot_table(index=['e', 'c'], columns="a", values="b"))
@@ -1089,19 +1090,19 @@ def test_pivot_table_errors(self):
1089
1090
1090
1091
kdf = ks .from_pandas (pdf )
1091
1092
1092
- msg = "values should be string or list of one column."
1093
+ msg = "Values should be string or list of one column."
1093
1094
with self .assertRaisesRegex (ValueError , msg ):
1094
1095
kdf .pivot_table (index = ['c' ], columns = "a" , values = 5 )
1095
1096
1096
- msg = "index should be a None or a list of columns."
1097
+ msg = "Index should be a None or a list of columns."
1097
1098
with self .assertRaisesRegex (ValueError , msg ):
1098
1099
kdf .pivot_table (index = "c" , columns = "a" , values = "b" )
1099
1100
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."
1101
1102
with self .assertRaisesRegex (NotImplementedError , msg ):
1102
1103
kdf .pivot_table (columns = "a" , values = ['b' , 'e' ], aggfunc = {'b' : 'mean' , 'e' : 'sum' })
1103
1104
1104
- msg = "columns should be string."
1105
+ msg = "Columns should be string."
1105
1106
with self .assertRaisesRegex (ValueError , msg ):
1106
1107
kdf .pivot_table (columns = ["a" ], values = ['b' ], aggfunc = {'b' : 'mean' , 'e' : 'sum' })
1107
1108
@@ -1110,9 +1111,18 @@ def test_pivot_table_errors(self):
1110
1111
kdf .pivot_table (index = ['e' , 'c' ], columns = "a" , values = 'b' ,
1111
1112
aggfunc = {'b' : 'mean' , 'e' : 'sum' })
1112
1113
1113
- msg = ' Values as list of columns is not implemented yet.'
1114
+ msg = " Values can't be a list without index."
1114
1115
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' ],
1116
1126
aggfunc = {'b' : 'mean' , 'e' : 'sum' })
1117
1127
1118
1128
def test_transpose (self ):
0 commit comments