Is there a way to cast a column to float that handle no numeric values? #3195
Answered
by
oleksiyskononenko
argenisleon
asked this question in
Q&A
-
Hi, is there a way to convert a column with string values to float? Something like this in pandas:
I am trying this approach using the
Is there a function in datatable that can handle this? |
Beta Was this translation helpful? Give feedback.
Answered by
oleksiyskononenko
Nov 1, 2021
Replies: 1 comment
-
What about just using casting? >>> from datatable import dt
>>> DT = dt.Frame(['apple', '1.0', '2', -3, None]/dt.str32)
>>> DT
| C0
| str32
-- + -----
0 | apple
1 | 1.0
2 | 2
3 | -3
4 | NA
[5 rows x 1 column]
>>> DT[0] = dt.float32
>>> DT
| C0
| float32
-- + -------
0 | NA
1 | 1
2 | 2
3 | -3
4 | NA
[5 rows x 1 column] In the general case, one can use .as_type(). |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
argenisleon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about just using casting?
In the general case, one can use .as_type().