@@ -218,6 +218,7 @@ def draw_pivot_tables(dft, problem_type, verbose, chart_format, depVar='', mk_di
218
218
def draw_pivot_tables_old (dft , verbose , chart_format , depVar = '' , mk_dir = None ):
219
219
#### Finally I have fixed the bugs in pivot tables due to "category" dtypes in data ##############
220
220
plot_name = 'Bar_Plots_Pivots'
221
+ cats = [i for i in dft .loc [:, dft .nunique () <= 15 ]]
221
222
cats = copy .deepcopy (cats )
222
223
cats = list (set (cats ))
223
224
dft = copy .deepcopy (dft )
@@ -226,8 +227,8 @@ def draw_pivot_tables_old(dft, verbose, chart_format, depVar='', mk_dir=None):
226
227
# colormaps = ['summer', 'rainbow','viridis','inferno','magma','jet','plasma']
227
228
# colormaps = ['Purples','Oranges','Reds','YlOrBr',
228
229
# 'YlOrRd','OrRd','PuRd','RdPu','BuPu',]
229
- N = len (cats )
230
- if N == 0 :
230
+ len_cats = len (cats )
231
+ if len_cats == 0 :
231
232
print ('No categorical or boolean vars in data set. Hence no pivot plots...' )
232
233
return None
233
234
#### You can set the number of subplots per row and the number of categories to display here cols = 2
@@ -236,17 +237,17 @@ def draw_pivot_tables_old(dft, verbose, chart_format, depVar='', mk_dir=None):
236
237
height_size = 5
237
238
stringlimit = 20
238
239
combos = combinations (cats , 2 )
239
- N = len (cats )
240
+ len_cats = len (cats )
240
241
sns .set_palette ("Set1" )
241
- if N <= 1 :
242
+ if len_cats <= 1 :
242
243
### if there are not many categorical variables, there is nothing to plot
243
244
return imgdata_list
244
- if len (nums ) == 0 :
245
+ if len (cats ) == 0 :
245
246
### if there are no numeric variables, there is nothing to plot
246
247
return imgdata_list
247
248
if depVar is not None or not depVar == '' or not depVar == []:
248
249
########### This works equally well for classification as well as Regression ###
249
- noplots = int ((N ** 2 - N ) / 2 )
250
+ noplots = int ((len_cats ** 2 - len_cats ) / 2 )
250
251
dicti = {}
251
252
counter = 1
252
253
cols = 2
@@ -1247,8 +1248,7 @@ def catscatter(data, colx, coly, ax, ratio=10):
1247
1248
1248
1249
1249
1250
############################################################################
1250
- def draw_catscatterplots (dft , cats , verbose ,
1251
- chart_format , mk_dir = None ):
1251
+ def draw_catscatterplots (dft , cats , verbose , chart_format , mk_dir = None ):
1252
1252
"""
1253
1253
The function draws catscatter plots for pairs of categorical variables in a data frame.
1254
1254
A catscatter plot is a type of scatter plot that shows the frequency of each combination
@@ -1266,6 +1266,7 @@ def draw_catscatterplots(dft, cats, verbose,
1266
1266
"""
1267
1267
imgdata_list = list ()
1268
1268
cat_len = len (cats )
1269
+ plot_name = "catscatter plot"
1269
1270
if len (cats ) == 0 :
1270
1271
#### If there are no categorical variables, nothing to plot here ######
1271
1272
return imgdata_list
@@ -1680,7 +1681,7 @@ def classify_print_vars(filename: str or pd.DataFrame, sep, max_rows_analyzed, m
1680
1681
print ('Could not find given target var in data set. Please check input' )
1681
1682
### return the data frame as is ############
1682
1683
return (dfte , depVar , id_cols , bool_vars , categorical_vars , continuous_vars , discrete_string_vars ,
1683
- date_vars , classes , problem_type , cols_list )
1684
+ date_vars )
1684
1685
cols_list = list_difference (list (dft ), depVar )
1685
1686
if dft [depVar ].dtype == object :
1686
1687
classes = dft [depVar ].unique ().tolist ()
0 commit comments