Reputation: 755
I have the following list:
[(Timestamp('2017-01-26 00:00:00'), -0.19),
(Timestamp('2018-04-05 10:00:00'), -0.15)]
I want to change the keys from timestamps into strings and get the following list
['2017-01-26 00:00:00',
'2018-04-05 10:00:00']
Can this be done with a single line of code?
Thank you.
Upvotes: 0
Views: 489
Reputation: 120409
Use a comprehension:
lst = [(Timestamp('2017-01-26 00:00:00'), -0.19),
(Timestamp('2018-04-05 10:00:00'), -0.15)]
dt = [str(t[0]) for t in lst]
print(dt)
# Output
['2017-01-26 00:00:00', '2018-04-05 10:00:00']
Upvotes: 2