# Import data with column items given as Quantity units and use Predict?

Posted 1 year ago
2164 Views
|
3 Replies
|
0 Total Likes
|
 In the column I import as xlsx or CSV I get this Quantity[1.35, "Kilograms"], I have tried flatten which works on one item but feeding in a full column does not work for me. QuantityMagnatude only works for me if I put the item directly into this function but it does not work when I put a variable in i.e. to process the whole column I am using the import Sample-Data-Animal-Weights.xlsx. This form of the import is also in Boston Home data main file. I have spent a lot of time trying to sort this. If I use Excel to extract the number I can run Predict, but because of inconsistency of decimal places this is time consuming. Attachments:
3 Replies
Sort By:
Posted 1 year ago
 Sorry, here is the Data file that I am using. Attachments:
 Hi Declan,The problem is that the quantities are imported as strings, see InputForm @ info. To extract the quantity magnitudes and generate the rules data2 = Thread[Rule[QuantityMagnitude@*ToExpression /@ info, animal]] I don't think Predict can deal with numeric -> nominal data. You will have to encode the animal names to integers.