Skip to content

Commit 3e6ccde

Browse files
author
minjk-bl
committed
Add numeric_only option to corr function
1 parent e8b3b87 commit 3e6ccde

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

visualpython/js/m_apps/Groupby.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,12 @@ define([
886886
// Method code generation
887887
//================================================================
888888
if (method != '') {
889-
methodStr.appendFormat('{0}()', method);
889+
let numericOnlyList = ['std', 'sum', 'mean', 'median', 'quantile'];
890+
if (numericOnlyList.includes(method)) {
891+
methodStr.appendFormat('{0}(numeric_only=True)', method);
892+
} else {
893+
methodStr.appendFormat('{0}()', method);
894+
}
890895
}
891896
}
892897

visualpython/js/m_stats/Regression.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ define([
464464
code.appendLine("# Mean Centering ");
465465
independentValue = com_util.formatString("{0}_MC", independentValue);
466466
moderatedValue = com_util.formatString("{0}_MC", moderatedValue);
467-
code.appendFormatLine("vp_df['{0}'] = vp_df[{1}] - vp_df[{2}].mean()", independentValue, independent, independent);
468-
code.appendFormatLine("vp_df['{0}'] = vp_df[{1}] - vp_df[{2}].mean()", moderatedValue, moderated, moderated);
467+
code.appendFormatLine("vp_df['{0}'] = vp_df[{1}] - vp_df[{2}].mean(numeric_only=True)", independentValue, independent, independent);
468+
code.appendFormatLine("vp_df['{0}'] = vp_df[{1}] - vp_df[{2}].mean(numeric_only=True)", moderatedValue, moderated, moderated);
469469
}
470470
// Model 1 to 3
471471
code.appendLine();
@@ -683,8 +683,8 @@ define([
683683
code.appendLine();
684684
code.appendLine("# Residual statistics");
685685
code.appendLine("display(Markdown('### Residual statistics'))");
686-
code.appendLine("display(pd.DataFrame(data={'Min':vp_residual.min(),'Max':vp_residual.max(),'Mean':vp_residual.mean(),");
687-
code.append(" 'Std. Deviation':vp_residual.std(),'N':vp_residual.count()}))");
686+
code.appendLine("display(pd.DataFrame(data={'Min':vp_residual.min(),'Max':vp_residual.max(),'Mean':vp_residual.mean(numeric_only=True),");
687+
code.append(" 'Std. Deviation':vp_residual.std(numeric_only=True),'N':vp_residual.count()}))");
688688
}
689689
if (normTest === true) {
690690
code.appendLine();

visualpython/js/m_visualize/Chart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,8 +1308,8 @@ define([
13081308
'numerical': [
13091309
{ label: 'count', method: 'count()' },
13101310
{ label: 'unique count', method: 'unique()' },
1311-
{ label: 'sum', method: 'sum()' },
1312-
{ label: 'average', method: 'mean()' },
1311+
{ label: 'sum', method: 'sum(numeric_only=True)' },
1312+
{ label: 'average', method: 'mean(numeric_only=True)' },
13131313
{ label: 'min', method: 'min()' },
13141314
{ label: 'max', method: 'max()' }
13151315
]

visualpython/js/m_visualize/Seaborn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,10 +944,10 @@ define([
944944
}
945945
if (chartType === 'barplot' && sortX !== '' && sortY !== '') {
946946
if (hue !== '' && sortHue !== '') {
947-
sortCode = com_util.formatString("{0}[{1}[{2}]=={3}].groupby({4})[{5}].mean().sort_values({6}).index"
947+
sortCode = com_util.formatString("{0}[{1}[{2}]=={3}].groupby({4})[{5}].mean(numeric_only=True).sort_values({6}).index"
948948
, state.data, state.data, state.hue, com_util.convertToStr(sortHue, sortHueText), sortX, sortY, sortTypeStr);
949949
} else {
950-
sortCode = com_util.formatString("{0}.groupby({1})[{2}].mean().sort_values({3}).index", state.data, sortX, sortY, sortTypeStr);
950+
sortCode = com_util.formatString("{0}.groupby({1})[{2}].mean(numeric_only=True).sort_values({3}).index", state.data, sortX, sortY, sortTypeStr);
951951
}
952952
} else if (chartType === 'countplot' && (sortX !== '' || sortY !== '')) {
953953
let countVar = sortX === ''? sortY: sortX;

0 commit comments

Comments
 (0)