I have a .txt data where columns 6 and 7 are GPS position in the form:
50;18.5701400N,4;07.7693770E
When I read it by read_csv I try to convert it to cartesian coordinates by using converters. I wrote the function for converter
convertFunc = lambda x : float((x[0:5]+x[6:12]).replace(';','.'))
convert = {6:convertFunc,7:convertFunc}
when I use it on single value it works how I would like:
convertFunc(myData.Lat[1])
Out [159]: 55.187110250000003
when I try to use it in read_csv it does not work
myData = DataFrame(read_csv('~/data.txt', sep=',' names=['A', 'B', 'C', 'D', 'E', 'Lat', 'Long'],converters=convert))
I have an error:
...
convertFunc = lambda x : float((x[0:5] + x[6:12]).replace(';', '.'))
ValueError: invalid literal for float(): DGPS ongitu
I don't know where do it wrong or what I misunderstand in converters? Or maybe anyone knows good way (package) to work with GPS data in that form?
(I think it can be some problem with lambda
When I want to apply my function to the column I have an error: TypeError: only length-1 arrays can be converted to Python scalars
)
names=
so thatread_csv
gets the column names from the header row.names=
but it does not change, have the same error.skiprows=1
? Maybe post a sample of yourdata.txt
so it's clear what the problem is.