Skip to content
Advertisement

Multiple data types in a python list

I have a list for birth data each record has 3 columns for [DOB, weight, height] as such:

JavaScript

I need to change the data types of this as they are all strings in the list I want the first item in the record to be datetime and then the rest to be floats. I have:

JavaScript

I get an attribute error:

JavaScript

I would like to achieve this just by utilizing pythons file IO operations. I also want to maintain each record of data together in a list within the main list I just want to update the datatypes.

Advertisement

Answer

Your code is incomplete, there may be unexpected variable coverage, you can try to use the list comprehension directly.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement