I have a document with dates and times inside.
I have converted them into datetime objects, but now
I am having trouble in putting the date and time together.
For instance, the first date is 2015-01-25 and the first time
is 14:05:41.274647.
Now I would like to see only one number of the format "%Y-%m-%d "%H:%M:%S.%f"
but if I write on python date 'and' time, I only get the time (see last line of the code).
How do I get them both?
by the way, despite of what I wrote on the last line,
I must be able to get the format "%Y-%m-%d "%H:%M:%S.%f"
for the whole list, and not just for the first value.
I have converted them into datetime objects, but now
I am having trouble in putting the date and time together.
For instance, the first date is 2015-01-25 and the first time
is 14:05:41.274647.
Now I would like to see only one number of the format "%Y-%m-%d "%H:%M:%S.%f"
but if I write on python date 'and' time, I only get the time (see last line of the code).
How do I get them both?
from astral import Astral from scipy import * from pylab import* import numpy as np from numpy import array import matplotlib.pyplot as plt import datetime from datetime import datetime, timezone import pandas as pd import pytz file=open('bird_jan25jan16.txt','r') #Turning datas in file into lists orig_date=[] orig_time=[] movements=[] for i in file: tempsplit=i.split(' ') orig_date.append(tempsplit[0]) orig_time.append(tempsplit[1]) movements.append(tempsplit[2]) orig_dates_list = [datetime.strptime(date, "%Y-%m-%d").date() for date in orig_date] #string to datetime conversion orig_time_list=[datetime.strptime(time, "%H:%M:%S.%f").time() for time in orig_time] #string to datetime conversion # print(orig_dates_list[0] and orig_time_list[0]) #date 'and' time
by the way, despite of what I wrote on the last line,
I must be able to get the format "%Y-%m-%d "%H:%M:%S.%f"
for the whole list, and not just for the first value.