Pandas convert date and time to float

In my case the .csv file had strings as date and time with the following format: 30/07/2017 21:01:17 I find this to be the simplest way to convert this column to float: df[‘dateTime’] = df[‘dateTime’].str.replace(‘/’, ”) df[‘dateTime’] = df[‘dateTime’].str.replace(‘:’, ”) df[‘dateTime’] = df[‘dateTime’].str.replace(‘ ‘, ”) df[‘dateTime’] = df[‘dateTime’].astype(float) So we are removing any signs and … Read more

Calculate execution time in Python

In any Python script you can easily count execution time. In Jupiter notebooks simply use built-in magic commands like %%time in the very beginning of the cell. Now with the IDEs like PyCharm you should use something like this: import datetime as dt t1 = dt.datetime.now() # your code here t2 = dt.datetime.now() ft = … Read more