@@ -21,6 +21,9 @@ export class MinMaxScaler {
2121 tensor_data = tf . tensor ( data )
2222 }
2323 else if ( ( data instanceof DataFrame ) || ( data instanceof Series ) ) {
24+ if ( data . dtypes . includes ( "string" ) ) {
25+ throw Error ( "Dtype Error: Cannot perform operation on string dtypes" )
26+ }
2427 tensor_data = tf . tensor ( data . values )
2528 }
2629 else {
@@ -50,6 +53,9 @@ export class MinMaxScaler {
5053 transform ( data ) {
5154
5255 if ( data instanceof Series ) {
56+ if ( data . dtypes . includes ( "string" ) ) {
57+ throw Error ( "Dtype Error: Cannot perform operation on string dtypes" )
58+ }
5359 let tensor_data = tf . tensor ( data . values )
5460 let output_data = tensor_data . sub ( this . min ) . div ( this . max . sub ( this . min ) ) . arraySync ( )
5561 return new Series ( output_data )
@@ -63,6 +69,9 @@ export class MinMaxScaler {
6369 }
6470
6571 } else if ( data instanceof DataFrame ) {
72+ if ( data . dtypes . includes ( "string" ) ) {
73+ throw Error ( "Dtype Error: Cannot perform operation on string dtypes" )
74+ }
6675 let tensor_data = tf . tensor ( data . values ) ;
6776 let output_data = tensor_data . sub ( this . min ) . div ( this . max . sub ( this . min ) ) . arraySync ( )
6877 return new DataFrame ( output_data )
@@ -85,6 +94,9 @@ export class StandardScaler {
8594 tensor_data = tf . tensor ( data )
8695 }
8796 else if ( ( data instanceof DataFrame ) || ( data instanceof Series ) ) {
97+ if ( data . dtypes . includes ( "string" ) ) {
98+ throw Error ( "Dtype Error: Cannot perform operation on string dtypes" )
99+ }
88100 tensor_data = tf . tensor ( data . values )
89101 }
90102 else {
@@ -109,6 +121,9 @@ export class StandardScaler {
109121 // }
110122
111123 if ( data instanceof Series ) {
124+ if ( data . dtypes . includes ( "string" ) ) {
125+ throw Error ( "Dtype Error: Cannot perform operation on string dtypes" )
126+ }
112127 let tensor_data = tf . tensor ( data . values )
113128 let output_data = tensor_data . sub ( this . mean ) . div ( this . std ) . arraySync ( )
114129 return new Series ( output_data )
@@ -121,6 +136,9 @@ export class StandardScaler {
121136 return new DataFrame ( output_data )
122137 }
123138 } else if ( data instanceof DataFrame ) {
139+ if ( data . dtypes . includes ( "string" ) ) {
140+ throw Error ( "Dtype Error: Cannot perform operation on string dtypes" )
141+ }
124142 let tensor_data = tf . tensor ( data . values ) ;
125143 let output_data = tensor_data . sub ( this . mean ) . div ( this . std ) . arraySync ( )
126144 return new DataFrame ( output_data )
0 commit comments