중복 열 제거안녕하세요:
400 개 이상의 열과 50,000 개의 행이있는 hugue 데이터 테이블이 있습니다. 30-40 개의 중복 열이 있는데 데이터 표에서 제거하려면. 어떤 아이디어?
제목 : Re : 중복 열 제거다음은 의도 된 용도로 "더 좋을"수도 있고 그렇지 않을 수도있는 무차별 (그리고 테스트되지 않은) 대안입니다 :
NamesDefaultToHere(1);
dt = CurrentDataTable();
// Make a matrix 'mat' holding pairwise equality of column values
n = NCol(dt);
mat = J(n, n, .);
for(c1 = 1, c1 <=n, c1++,
for(c2 = c1+1, c2 <= n, c2++,
c1Vals = Column(dt, c1) << getValues;
c2Vals = Column(dt, c2) << getValues;
mat[c1, c2] = all(c1Vals == c2Vals);
);
);
// Convert 'mat' to a table
cols = dt << getColumnNames("String");
dtn = dt << getName;
dt2 = AsTable(mat, << columnNames(cols));
dt2 << setName("Duplicate Columns in "||dtn);
dt2 << NewColumn("Column", Character, Values(cols));
dt2 << moveSelectedColumns({"Column"}, ToFirst);제목 : Re : 중복 열 제거당신은 MD5 체크섬 , 블롭 MD5 () 함수를 사용하여 열의 값 해시를 생성 한 다음 열 사이의 체크섬을 비교합니다.
연관 배열을 사용하여 중복 된 md5 체크섬이 생성 될 때이를 검사하여 모든 체크섬을 다른 모든 체크섬과 직접 비교하지 않아도됩니다.
dt = New Table( "Some Duplicate Columns",
Add Rows( 1000 ),
New Column( "Column 1", Numeric, "Continuous", Format( "Best", 12 ), Formula( Random Normal() ) ),
New Column( "Copy of Column 1", Numeric, "Continuous", Format( "Best", 12 ), Formula( :Column 1 ) ),
New Column( "Not a copy of Column 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( If( Row() == 1, 1, :Column 1 ) )
),
New Column( "Character copy of Column 1", Character, "Nominal", Formula( Char( :Column 1 ) ) ),
New Column( "Character copy of Copy of Column 1",
Character,
"Nominal",
Formula( Char( :Copy of Column 1 ) ),
)
);
//get values into matrix (numeric columns) or list (character columns)
c1 = :column 1 << get values;
c2 = :Copy of Column 1 << get values;
//avoid having to check column data types when converting the values to blob
//by converting matrix or list to character
//
//if you're not lazy you could use the Matrix to Blob() function for numeric columns
//and the Char to Blob() function for character columns
char_c1 = Char( c1 );
char_c2 = Char( c2 );
c1_md5 = Blob MD5( Char To Blob( char_c1 ) );
c2_md5 = Blob MD5( Char To Blob( char_c2 ) );
Show( c1_md5 == c2_md5 );
//check the whole data table using hex version of md5 as keys of associative array
aa = Associative Array();
For( i = 1, i <= N Col( dt ), i++,
md5 = Hex( Blob MD5( Char To Blob( Char( Column( dt, i ) << get values ) ) ) );
//check to see if the associate array already has a key named with this md5
If( aa << Contains( md5 ),
//aa does contain md5
Print( aa[md5] || " is a duplicate of " || (Column( dt, i ) << get name) ),
//aa does not contain md5
//store a key named with this md5 with a value of the column name
aa[md5] = Column( dt, i ) << get name;
);
);
제목 : Re : 중복 열 제거왜 중복 열이 너무 많습니까? 이 결과를 예방할 수 있습니까?
제목 : Re : 중복 열 제거안녕하세요,
오늘 같은 문제가 발생했습니다. 여기 복제본을 제거하는 스크립트가 있습니다.
수천 개의 행이있는 테이블이 있으면 실제로 시간이 걸립니다. 그것을 할 수있는보다 효율적인 방법이 있어야합니다. 누군가가 알아서 공유 할 수 있기를 바랍니다.
Names Default To Here( 1 );
col_name = dt << get column names;
dup_col = {}; //store the duplicated column name
same_c = 0; //to record how many rows are the same while doing columns comparison
/* When the elements are the same in the same row for 2 columns, same_c will be added by 1*/
/*If the same_c is equal to the total row number, then the 2 columns are the same. Insert the column name into dup_col*/
For( i = 1, i <= (N Cols( dt ) - 1), i++,
For( k = i + 1, k <= N Cols( dt ), k++,
(For Each Row( If( :(col_name[i])[Row()] == :(col_name[k])[Row()], same_c++, Wait( 0 ) ) ) ;
If( same_c == N Rows( dt ), Insert Into( dup_col, col_name[k] ), Wait( 0 )) ;
same_c = 0 ; )
)
);
dt << Delete Column( Eval( dup_col ) );
// delete the duplicated columns
제목 : Re : 중복 열 제거나는 이것을 수행하는 내장 JMP 방법을 알지 못한다. 그러나 RSquare 통계를 사용하여 열이 동일한 지 확인할 수 있습니다.
이 작업을 대화 형으로 수행하려는 경우에는 다음을 사용하여 연속 열을 식별 할 수 있습니다.
분석 ==> 다 변수 방법 ==> 다 변수
데이터 테이블로 출력 할 수있는 중심 맞춤 행렬을 제공 한 다음이를 사용하여 상관 관계가 1 인 열을 식별합니다.
ordinal / nominal 컬럼은 RSquare 테이블에서 X로 Y 축으로 "Make Combined Data Table"을 생성하여 식별 할 수 있습니다. 다시 한번 1.0의 RSquare는 컬럼이 동일하다는 단서를 제공합니다.
이제 솔루션을 스크립팅 할 경우 위의 내용을 상당히 쉽게 자동화 할 수 있습니다.
어쩌면 다른 커뮤니티 회원이 더 나은 해결책을 가지고있을 것입니다.