Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6934c50

Browse files
author
minjk-bl
committed
columnSelector renewal - allow multi frame
1 parent07bb746 commit6934c50

File tree

5 files changed

+78
-22
lines changed

5 files changed

+78
-22
lines changed

‎src/api/functions/pandasCommand.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ def _vp_get_columns_list(df):
4747
colList.append(cInfo)
4848
returncolList
4949

50+
def_vp_get_multi_columns_list(dfs= []):
51+
"""
52+
Get Columns List with Detail Information of multiple dataframe
53+
"""
54+
common_set= {}
55+
fordfindfs:
56+
common_set=common_set&set(df)
57+
common_columns=list(common_set)
58+
59+
colList= []
60+
fori,cinenumerate(common_columns):
61+
cInfo= {'label':c,'value':c,'dtype':str(dfs[0][c].dtype),'location':i }
62+
# value
63+
iftype(c).__name__=='str':
64+
cInfo['value']="'{}'".format(c)
65+
eliftype(c).__name__=='Timestamp':
66+
cInfo['value']=str(c)
67+
colList.append(cInfo)
68+
returncolList
69+
5070
def_vp_get_column_category(df,col):
5171
"""
5272
Get Column's Uniq values(Categrical data only, limit 20)

‎src/api_block/constData.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,14 +816,14 @@ define([
816816
tooltip:'Work In Progress',// FIXME:
817817
file:'nbextensions/visualpython/src/common/vpMerge',
818818
icon:'/nbextensions/visualpython/resource/apps/apps_merge.svg',
819-
color:0,
819+
color:3,
820820
},
821821
'reshape':{
822822
label:'Reshape',
823823
tooltip:'Work In Progress',// FIXME: 'Pivot & Melt',
824824
file:'nbextensions/visualpython/src/common/vpReshape',
825825
icon:'/nbextensions/visualpython/resource/apps/apps_reshape.svg',
826-
color:0,
826+
color:3,
827827
},
828828
'chart':{
829829
label:'Chart',

‎src/common/component/vpColumnSelector.js‎

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,60 @@ define([
4949
/**
5050
*
5151
*@param {string} frameSelector query for parent component
52-
*@param {string} dataframe dataframe variable name
52+
*@param {Object} config dataframe:[], selectedList=[], includeList=[]
53+
*@param {Array<string>} dataframe dataframe variable name
5354
*@param {Array<string>} selectedList
5455
*@param {Array<string>} includeList
5556
*/
56-
constructor(frameSelector,dataframe,selectedList=[],includeList=[]){
57+
constructor(frameSelector,config){
5758
this.uuid='u'+vpCommon.getUUID();
5859
this.frameSelector=frameSelector;
60+
61+
// configuration
62+
var{ dataframe, selectedList=[], includeList=[]}=config;
5963
this.dataframe=dataframe;
6064
this.selectedList=selectedList;
6165
this.includeList=includeList;
66+
6267
this.columnList=[];
6368
this.pointer={start:-1,end:-1};
6469

6570
varthat=this;
66-
kernelApi.getColumnList(dataframe,function(result){
67-
varcolList=JSON.parse(result);
68-
colList=colList.map(function(x){
69-
return{
70-
...x,
71-
value:x.label,
72-
code:x.value
73-
};
71+
if(dataframe&&dataframe.length>1){
72+
kernelApi.getCommonColumnList(dataframe,function(result){
73+
varcolList=JSON.parse(result);
74+
colList=colList.map(function(x){
75+
return{
76+
...x,
77+
value:x.label,
78+
code:x.value
79+
};
80+
});
81+
if(includeList&&includeList.length>0){
82+
that.columnList=colList.filter(col=>includeList.includes(col.code));
83+
}else{
84+
that.columnList=colList;
85+
}
86+
that.load();
7487
});
75-
if(includeList&&includeList.length>0){
76-
that.columnList=colList.filter(col=>includeList.includes(col.code));
77-
}else{
78-
that.columnList=colList;
79-
}
80-
that.load();
81-
that.bindEvent();
82-
that.bindDraggable();
83-
});
88+
}else{
89+
kernelApi.getColumnList(dataframe,function(result){
90+
varcolList=JSON.parse(result);
91+
colList=colList.map(function(x){
92+
return{
93+
...x,
94+
value:x.label,
95+
code:x.value
96+
};
97+
});
98+
if(includeList&&includeList.length>0){
99+
that.columnList=colList.filter(col=>includeList.includes(col.code));
100+
}else{
101+
that.columnList=colList;
102+
}
103+
that.load();
104+
});
105+
}
84106
}
85107

86108
_wrapSelector(query=''){
@@ -90,6 +112,8 @@ define([
90112
load(){
91113
$(vpCommon.wrapSelector(this.frameSelector)).html(this.render());
92114
vpCommon.loadCssForDiv(this._wrapSelector(),Jupyter.notebook.base_url+vpConst.BASE_PATH+vpConst.STYLE_PATH+'common/component/columnSelector.css');
115+
this.bindEvent();
116+
this.bindDraggable();
93117
}
94118

95119
getColumnList(){

‎src/common/kernelApi.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ define([
6969
});
7070
}
7171

72+
vargetCommonColumnList=function(dataframeList,callback){
73+
executePython(
74+
vpCommon.formatString('_vp_print(_vp_get_multi_columns_list([{0}]))',dataframeList.join(','))
75+
,function(result){
76+
callback(result);
77+
});
78+
}
79+
7280
vargetRowList=function(dataframe,callback){
7381
executePython(
7482
vpCommon.formatString('_vp_print(_vp_get_rows_list({0}))',dataframe)
@@ -87,6 +95,7 @@ define([
8795
executePython:executePython,
8896
searchVarList:searchVarList,
8997
getColumnList:getColumnList,
98+
getCommonColumnList:getCommonColumnList,
9099
getRowList:getRowList,
91100
getProfilingList:getProfilingList
92101
}

‎src/common/vpGroupby.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,10 @@ define([
485485
*@param {Array<string>} includeList columns to include
486486
*/
487487
renderColumnSelector(previousList,includeList){
488-
this.popup.ColSelector=newvpColumnSelector(this._wrapSelector('.'+APP_POPUP_BODY),this.state.variable,previousList,includeList);
488+
this.popup.ColSelector=newvpColumnSelector(
489+
this._wrapSelector('.'+APP_POPUP_BODY),
490+
{dataframe:[this.state.variable],selectedList:previousList,includeList:includeList}
491+
);
489492
}
490493

491494
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp