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

Select dataframe rows by specific column string values in Pandas

Hello, I’m back! 😎 Now the traditional method is this: df.loc[df[‘column_name’] == value] For string, and for numeric values this: df.loc[df[‘column_name’] == ‘string’] While it always work with numeric values, for string values sometimes it doesn’t work. It picks up a blank dataframe. I guess it’s something to do with encoding of the source where … Read more

Convert to Timestamp (DateTime) pandas time column with dates sliced in-between as headers

Hey guys. Being pretty average at Pandas, yesterday I stumbled upon a formatting challenge. I download some datasheets from the web for machine learning from time to time. This time I got some weird Time & date formatting which might’ve been good for regular use with Excel but unsuitable when it comes to Neural Networks: … Read more