Suppose I want to convert the first col of a PDL::Char to a float. When I do 
this

    my $age_col=$self->data->slice(",0:0");

I get the first column just fine, it looks like this

[
 [ '39'  ]
 [ '50'  ]
 [ '38'  ]
 [ '53'  ]
 [ '28'  ]
 [ '37'  ]
 [ '49'  ]
 [ '52'  ]
 [ '31'  ]
 [ '42'  ]
 [ '37'  ]
 [ '30'  ]
 [ '23'  ]
 [ '32'  ]
 [ '40'  ]
 [ '34'  ]
]

but if I try and convert it to a float I get a bunch of gibberish?
    my $age_col=$self->data->slice(",0:0");
    $age_col = float $age_col;

[
 [ 'LBdB'  ]
 [ 'TB@B'  ]
 [ 'LB`B'  ]
 [ 'TBLB'  ]
 [ 'HB`B'  ]
 [ 'LB\B'  ]
 [ 'PBdB'  ]
 [ 'TBHB'  ]
 [ 'LBDB'  ]
 [ 'PBHB'  ]
 [ 'LB\B'  ]
 [ 'LB@B'  ]
 [ 'HBLB'  ]
 [ 'LBHB'  ]
 [ 'PB@B'  ]
 [ 'LBPB'  ]
]


What am I doing wrong?
I am using PDL:Char because much of the rest of the columns are indeed Strings 
and so I thought it wuld make sense to just use PDL::Char to store everything 
and then selectively convert a column or two to float as needed.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to