# How to separate the real part of elements in a list? [closed]

I have this list of complex numbers, and I like to just have the real parts. but this happens;

mylist = {"-0.0008254407622034586 - 0.00027208294839600484*I",
"-0.002337775697077904 - 0.0010944345849494001*I",
"0.0007542764998269973 - 0.0015145500329643122*I",
"-0.0010752208480672588 + 0.002930836636307818*I",
0.470030622499595,
"-0.46317756817175976 - 0.0052659322646682214*I"}

Re[mylist]
{Re["-0.0008254407622034586 - 0.00027208294839600484*I"],
Re["-0.002337775697077904 - 0.0010944345849494001*I"],
Re["0.0007542764998269973 - 0.0015145500329643122*I"],
Re["-0.0010752208480672588 + 0.002930836636307818*I"], 0.470031,
Re["-0.46317756817175976 - 0.0052659322646682214*I"]}


How can I get the Real parts only?

• the elements of your list are strings and not numbers, you should convert them to numbers first. Try to look for ToExpression, or maybe revisit the way you import the data Dec 6 '19 at 17:13
• Re@*ToExpression /@ mylist will work, but as @Fraccalo mentioned, it would be much better if you found out why your numbers are not numbers but strings: that would fix the problem at the source. Dec 6 '19 at 17:15

Try this:

Re /@ ToExpression /@ mylist

(* {-0.000825441, -0.00233778, 0.000754276, -0.00107522, 0.470031,-0.463178}  *)


Have fun!

An alternative way to use ToExpression and Re:

ToExpression[mylist, StandardForm, Re]
`

{-0.0008254407622034586, -0.002337775697077904, 0.0007542764998269973, -0.0010752208480672588, 0.470030622499595, -0.46317756817175976}