#๐Ÿ”’ Datetime format.

21 messages ยท Page 1 of 1 (latest)

brazen oyster
#

I have a dataset in excel where the datetime column in the order dd-mm-yy hh-mm, but upon importing the dataset on jupyter notebook and putting the data into a dataframe, for some rows the format is changing to yy-mm-dd hh-mm which is why i am having trouble converting it into datetime format on python. I am a beginner and my assignment is due today. idk what to do ๐Ÿ˜ฆ

autumn barnBOT
#

@brazen oyster

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

proven garnet
#

!d datetime.datetime.strftime

autumn barnBOT
#

datetime.strftime(format)```
Return a string representing the date and time, controlled by an explicit format string. See also [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior) and [`datetime.isoformat()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.isoformat).
brazen oyster
proven garnet
#

As a method called off a datetime object, that object representing a date and time, strftime allows you to specify a format of the time data in the string returned.

#

I can demonstrate, but give me a moment

brazen oyster
proven garnet
#

!e py from datetime import datetime now = datetime.now() print(now) print(now.strftime('The month is %B and the year is %Y'))

autumn barnBOT
proven garnet
#

There may be equivalent strftime methods or parameters available more specific to what you're doing.

#

Check the ugd object's methods. I don't use Pandas.

brazen oyster
#

I am still quite unsure what to do but thank you for giving me some direction. i will try a few things and let you know.

proven garnet
#

There will probably be something in Pandas into which you can pass the dataframe and the strftime string or functionality attached to the dataframe that is called strftime that you can give an sttftime string to.

brazen oyster
#

Code:

# Loading the Excel file and creating dataframes
file_path=""
ugd = pd.read_excel(file_path, sheet_name = "User Gameplay data", skiprows=3 ) 
dd = pd.read_excel(file_path, sheet_name = "Deposit Data", skiprows=3)
wd= pd.read_excel(file_path, sheet_name = "Withdrawal Data", skiprows=3) 
#

What am I missing?

autumn barnBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.