Javatpoint Logo
Javatpoint Logo

Convert string to date

In today's time, it is a tedious task to analyze datasets with dates and times. Because of different lengths in months, distributions of the weekdays and weekends, leap years, and the time zones are the things that needs to consider according to our context. So, for this reason, Python has defined a new data type especially for dates and times called datetime.

However, in many datasets, Strings are used to represent the dates. So, in this topic, you'll learn about converting date strings to the datetime format and see how these powerful set of tools helps to work effectively with complicated time series data.

The challenge behind this scenario is how the date strings are expressed. For example, 'Wednesday, June 6, 2018' can also be shown as '6/6/18' and '06-06-2018'. All these formats define the same date, but the code represents to convert each of them is slightly different.

Output:

2017-07-14 00:00:00
2017-07-14 00:00:00
2018-07-14 00:00:00

Converting the date string column

This conversion shows how to convert whole column of date strings from the dataset to datetime format.

From now on, you have to work with the DataFrame called eth that contains the historical data on ether, and also a cryptocurrency whose blockchain is produced by the Ethereum platform. The dataset consists the following columns:

  • date: Defines the actual date, daily at 00:00 UTC.
  • txVolume: It refers an unadjusted measure of the total value in US dollars, in outputs on the blockchain.
  • txCount: It defines number of transactions performed on public blockchain.
  • marketCap: Refers to the unit price in US dollars multiplied by the number of units in circulation.
  • price: Refers an opening price in US dollars at 00:00 UTC.
  • generatedCoins: Refers the number of new coins.
  • exchangeVolume: Refers the actual volume which is measured by US dollars, at exchanges like GDAX and Bitfinex.

Next TopicPandas Plot





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA