Skip to content
Advertisement

How to change data type in a list of tuples if this type is Timestamp?

I have a list of tuples like this:

JavaScript

What I do is:

JavaScript

How can I do to change directly the Timestamp type in this list of tuples ? More precisely, if type is pd.Timestamp I would like to change it to np.datetime64.

Advertisement

Answer

This is an example that should explain what you are missing.

JavaScript

The result:

[[’12’, 123, ‘test_1′], [’14’, 456, ‘test_2’]]

[[’12’, ‘123’, ‘test_1′], [’14’, ‘456’, ‘test_2’]]

So the complete answer is: don’t change tuples and use indexes to change the content of your list.

But I would create a new list and not change the existing one. Something like this:

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