• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Python 3 importing CSV file and converting time to be able to plot

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok my problem is the following I have a CSV that looks like the following
ML INT .10 534.15 0:00
ML EXT .25 654.23 3:00
ML INT .35 743.12 6:30

I want to be able to plot the 4th column as x axis and 5th column as y axis . the y axis will be in 12 hr format from 0:00 to 11:59
I would also like to color code the scatterplot so that INT and EXT will be either blue or red

But my problem is when i try to import the CSV it gives me an error. the following

ValueError: could not convert string to float: b'1:00'
and also ValueError: could not convert string to float

now i guess i can only import numbers that way and not txt and o clock format

any suggestions or ideas as to how i can convert this data so i can plot??

this is the code i have so far
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

any suggestions or ideas as to how i can convert this data so i can plot??


Write a routine that converts time values to float values that can be graphed?
 
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hank Harrison,

Your problem appears when you try to use string instead of float data type.
You need to find the way, how to cast string to a float type.

I'm not sure what exactly you're trying to do, if you'd explain a bit more, probably someone could help you a bit more precisely.
reply
    Bookmark Topic Watch Topic
  • New Topic