Gmousse/dataframe-js

dataframe.js and dataframe-min.js bug

Closed this issue · 10 comments

hello Gmousse , maybe i found a bug about import data frame.js .

when i import dataframe.js , i join two data frame , performance is too slower , caught browser core dump,

when ii import dataframe-min.js , program give a error "TypeError: t expected as one of [DataFrame], not as a object | t " .

i think , maybe it is a bug .

Gmousse , thank you for a powerful js package to support DataFrame .

Hi @wustevens,

About the slowness of the join, I will work on a new optimize version of the library (but when ?).

Can you give me the piece of code you used to import the dataframe-min.js ?
Can you give me the complete error log (and where the error is throw) ?

Thank you

hi @Gmousse , when i import dataframe-min.js

<script src="https://cdn.rawgit.com/Gmousse/dataframe-js/master/dist/dataframe-min.js"></script>

and then ,

result = ( new dfjs.DataFrame( symbol , _.keys( symbol[ 0 ] ) ) ).join( result , [ 'exchange' , 'symbol' ] , 'inner' ) ;

result is DataFrame type data .

system give me a error !

[Error] Error: t expected as one of [DataFrame], not as a object | t.
n@https://cdn.rawgit.com/Gmousse/dataframe-js/master/dist/dataframe-min.js:5:7276
u@https://cdn.rawgit.com/Gmousse/dataframe-js/master/dist/dataframe-min.js:5:6383
https://cdn.rawgit.com/Gmousse/dataframe-js/master/dist/dataframe-min.js:5:6607
forEach@[native code]
https://cdn.rawgit.com/Gmousse/dataframe-js/master/dist/dataframe-min.js:5:6585
stock@http://127.0.0.1:2345/static/utils/js/datatable.js:239:76
update@http://127.0.0.1:2345/static/utils/js/controller.js:885:27
http://127.0.0.1:2345/static/utils/js/controller.js:862:51
https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js:11477:15
processQueue@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js:16383:30
https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js:16399:39
$digest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js:17495:36
$apply@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js:17790:31
done@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js:11831:53
completeRequest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js:12033:15
requestLoaded@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js:11966:24
(匿名函数) (angular.js:10467)
processQueue (angular.js:16391)
(匿名函数) (angular.js:16399)
$digest (angular.js:17495)
$apply (angular.js:17790)
done (angular.js:11831)
completeRequest (angular.js:12033)
requestLoaded (angular.js:11966)

let result = _.reduce( indicators , function( prev , item , name ) {
// 过滤 数据

			let data = _.filter( item.data , row => ( row[ name ] >= Number( item.min ) && row[ name ] <= Number( item.max ) ) );

			// 做 关联处理

			if ( data === null || data.length <= 0 ) {
				return prev;
			} else if ( prev === undefined || prev === null ) {
				return new dfjs.DataFrame( data , _.keys( data[ 0 ] ) );
			} else {
				return prev.join( ( new dfjs.DataFrame( data , _.keys( data[ 0 ] ) ) ) ,
				                  [ 'exchange' , 'symbol' , 'annual_date' , 'annual_type' , 'trade_date' ] ,
				                  'inner' );
			}
		} , null );

@wustevens I will investigate in few hours.
If the bug doesn't appear with the non-minify version, it's maybe due to a webpack missconfiguration.

thanks for this report

@Gmousse , thanks for your work .

hi , @Gmousse

when i import dataframe.js , non-min package , join operate performance is slow .
i join left df ( rows is 3 ) and right df ( rows is 205 ), but no return df , always running .

@Gmousse , Do you think where is a problem with my program?

Here is my code :

typeof symbol
< "object"
_.first( symbol , 2 )
< Array (2) = $2
0 {delist_date: "Mon, 01 Jan 1900 00:00:00 GMT", exchange: "SH", ipo_date: "Mon, 01 Jan 1900 00:00:00 GMT", notes: "主板", security_name: "浦发银行", …}
1 {delist_date: "Mon, 01 Jan 1900 00:00:00 GMT", exchange: "SH", ipo_date: "Mon, 01 Jan 1900 00:00:00 GMT", notes: "主板", security_name: "白云机场", …}

“Array”原型

symbol.length
< 1125
typeof result
< "object"
result.dim()
< [205, 9] (2)
result.show(2)
< "| annual... | annual... | compan... | currency | curren... | exchange | symbol | trade_... | 总市值/净利润 |


| Wed, 3... | 1 | B | CNY | Millons | SH | 600000 | Thu, 1... | 7.108 |
| Wed, 3... | 1 | G | CNY | Millons | SH | 600004 | Thu, 1... | 12.762 |"

( ( new dfjs.DataFrame( _.first( symbol , 3 ) , _.keys( symbol[ 0 ] ) ) ).join( result , [ 'exchange' , 'symbol' ] , 'inner' ) ).show()

Thanks you .

@wustevens hi
Indeed, I have realized some tests about joins, indeed it's really slow.
I m little busy this time but I plan to fix this performance issue this week-end.

For the -min issue, it's probably due to the uglify plugin and the checktype module I use.
I will take a look tomorrow .

hi @Gmousse , Looking forward to your solution , Thanks you.

hi @wustevens.
Sorry to be late, I couldn't work on this project the last 2 months.

Yesterday I have fixed your issues and publish them on the tag 1.2.3.
The join method worked but had a strange behavior leading on performance issues.
Now it should work correctly and faster than ever.

For your issues on dataframe-min, It's related with type checking and uglification.
I have created a specific issue #23 and will work on it soon.

@wustevens The dataframe-min.js build is repaired (effective from the 1.2.3 and available). It was a uglifyjs relative issue and I have repaired it by a custom configuration in my webpack.config.js. #23

Please, be free to use the -min bundle.