COMPUTER SCIENCE AND ENGINEERING
MACHINE LEARNING
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
2020-04-24
|
|
2020-24-04
|
|
2020-April-04
|
|
2020-24-April
|
Detailed explanation-1: -Converting a String to a datetime object using datetime.strptime() The datetime.strptime() method returns a datetime object that matches the date string parsed by the format. Both arguments are required and must be strings.
Detailed explanation-2: -Use datetime.strftime(format) to convert a datetime object into a string as per the corresponding format . The format codes are standard directives for mentioning in which format you want to represent datetime. For example, the %d-%m-%Y %H:%M:%S codes convert date to dd-mm-yyyy hh:mm:ss format.
Detailed explanation-3: -For this, we will use the strptime() method and Pandas module. This method is used to create a DateTime object from a string. Then we will extract the date from the DateTime object using the date() function and dt. date from Pandas in Python.