Quantcast

How to vonvet Char to Float64, what wrong ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to vonvet Char to Float64, what wrong ?

programistawpf
How to convert Char  to Float? What wrong ?

julia> eltype(sort(unique(dane[:,4]))[3])
Char

julia> (sort(unique(dane[:,4]))[3])
"-.097"

julia> convert(Float64(sort(unique(dane[:,4]))[3]))
ERROR: MethodError: `convert` has no method matching convert(::Type{Float64}, ::UTF8String)
This may have arisen from a call to the constructor Float64(...),
since type constructors fall back to convert methods.
Closest candidates are:
  call{T}(::Type{T}, ::Any)
  convert(::Type{Float64}, ::Int8)
  convert(::Type{Float64}, ::Int16)
  ...
 in call at essentials.jl:56

paul
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to vonvet Char to Float64, what wrong ?

Jeffrey Sarnoff
if `a = sort(unique(dane[:,4])[3])`, what is `(a, typeof(a))`?

On Friday, November 25, 2016 at 3:35:21 AM UTC-5, [hidden email] wrote:

> How to convert Char  to Float? What wrong ?
>
> julia> eltype(sort(unique(dane[:,4]))[3])
> Char
>
> julia> (sort(unique(dane[:,4]))[3])
> "-.097"
>
> julia> convert(Float64(sort(unique(dane[:,4]))[3]))
> ERROR: MethodError: `convert` has no method matching convert(::Type{Float64}, ::UTF8String)
> This may have arisen from a call to the constructor Float64(...),
> since type constructors fall back to convert methods.
> Closest candidates are:
>   call{T}(::Type{T}, ::Any)
>   convert(::Type{Float64}, ::Int8)
>   convert(::Type{Float64}, ::Int16)
>   ...
>  in call at essentials.jl:56
>
> paul

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to vonvet Char to Float64, what wrong ?

Jeffrey Sarnoff
In reply to this post by programistawpf
what is `a` and `typeof(a)` where `a = sort(unique(dane[:,4]))[3])`



On Friday, November 25, 2016 at 3:35:21 AM UTC-5, [hidden email] wrote:

> How to convert Char  to Float? What wrong ?
>
> julia> eltype(sort(unique(dane[:,4]))[3])
> Char
>
> julia> (sort(unique(dane[:,4]))[3])
> "-.097"
>
> julia> convert(Float64(sort(unique(dane[:,4]))[3]))
> ERROR: MethodError: `convert` has no method matching convert(::Type{Float64}, ::UTF8String)
> This may have arisen from a call to the constructor Float64(...),
> since type constructors fall back to convert methods.
> Closest candidates are:
>   call{T}(::Type{T}, ::Any)
>   convert(::Type{Float64}, ::Int8)
>   convert(::Type{Float64}, ::Int16)
>   ...
>  in call at essentials.jl:56
>
> paul

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to vonvet Char to Float64, what wrong ?

Milan Bouchet-Valat
In reply to this post by programistawpf
Le vendredi 25 novembre 2016 à 00:35 -0800, [hidden email] a
écrit :
> How to convert Char  to Float? What wrong ?
Use parse(Float64, string(x)), with x the Char.


Regards


> julia> eltype(sort(unique(dane[:,4]))[3])
> Char
>
> julia> (sort(unique(dane[:,4]))[3])
> "-.097"
>
> julia> convert(Float64(sort(unique(dane[:,4]))[3]))
> ERROR: MethodError: `convert` has no method matching
> convert(::Type{Float64}, ::UTF8String)
> This may have arisen from a call to the constructor Float64(...),
> since type constructors fall back to convert methods.
> Closest candidates are:
>   call{T}(::Type{T}, ::Any)
>   convert(::Type{Float64}, ::Int8)
>   convert(::Type{Float64}, ::Int16)
>   ...
>  in call at essentials.jl:56
>
> paul
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to vonvet Char to Float64, what wrong ?

Yichao Yu
On Fri, Nov 25, 2016 at 8:48 AM, Milan Bouchet-Valat <[hidden email]> wrote:
> Le vendredi 25 novembre 2016 à 00:35 -0800, [hidden email] a
> écrit :
>> How to convert Char  to Float? What wrong ?
> Use parse(Float64, string(x)), with x the Char.
>

He actually has a string and not a char so no need for the string part.

Also, please stop posting on this list and move to
https://discourse.julialang.org/

>
> Regards
>
>
>> julia> eltype(sort(unique(dane[:,4]))[3])
>> Char
>>
>> julia> (sort(unique(dane[:,4]))[3])
>> "-.097"
>>
>> julia> convert(Float64(sort(unique(dane[:,4]))[3]))
>> ERROR: MethodError: `convert` has no method matching
>> convert(::Type{Float64}, ::UTF8String)
>> This may have arisen from a call to the constructor Float64(...),
>> since type constructors fall back to convert methods.
>> Closest candidates are:
>>   call{T}(::Type{T}, ::Any)
>>   convert(::Type{Float64}, ::Int8)
>>   convert(::Type{Float64}, ::Int16)
>>   ...
>>  in call at essentials.jl:56
>>
>> paul
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to vonvet Char to Float64, what wrong ?

Waldir Pimenta
On Friday, November 25, 2016 at 3:13:51 PM UTC, Yichao Yu wrote:
>
> Also, please stop posting on this list and move to
> https://discourse.julialang.org/
>

Wasn't this list locked for new posts? Maybe there's something wrong with the configuration.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to vonvet Char to Float64, what wrong ?

Waldir Pimenta
On Friday, November 25, 2016 at 4:47:07 PM UTC, Waldir Pimenta wrote:
> On Friday, November 25, 2016 at 3:13:51 PM UTC, Yichao Yu wrote:
> >
> > Also, please stop posting on this list and move to
> > https://discourse.julialang.org/
> >
>
> Wasn't this list locked for new posts? Maybe there's something wrong with the configuration.

Sorry, I meant new threads.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to vonvet Char to Float64, what wrong ?

Stefan Karpinski
It was set correctly but for some reason didn't work even though the same change worked correctly on julia-dev. The Google Groups admin tools are a train wreck of brokenness and confusion – one of the many reasons we're moving away. I had to go through and manually set everyone's posting permissions, so hopefully now people can't post. Admins and managers will still occasionally use this list for announcements since we probably won't get most people to join Discourse immediately.

On Fri, Nov 25, 2016 at 11:47 AM, Waldir Pimenta <[hidden email]> wrote:
On Friday, November 25, 2016 at 4:47:07 PM UTC, Waldir Pimenta wrote:
> On Friday, November 25, 2016 at 3:13:51 PM UTC, Yichao Yu wrote:
> >
> > Also, please stop posting on this list and move to
> > https://discourse.julialang.org/
> >
>
> Wasn't this list locked for new posts? Maybe there's something wrong with the configuration.

Sorry, I meant new threads.

Loading...