Python Forum
Does a pandas have a date without a time?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Does a pandas have a date without a time?
#6
There is dt which has date:

>>> import pandas as pd
>>> df = pd.DataFrame(pd.date_range("2021-01-01", periods=3, freq="s"))
>>> df
                    0
0 2021-01-01 00:00:00
1 2021-01-01 00:00:01
2 2021-01-01 00:00:02
>>> df[0].dt.date
0    2021-01-01
1    2021-01-01
2    2021-01-01
Name: 0, dtype: object
>>> df[0].dt.year
0    2021
1    2021
2    2021
Name: 0, dtype: int64
>>> df[0].dt.day
0    1
1    1
2    1
Name: 0, dtype: int64
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: Does a pandas have a date without a time? - by perfringo - Feb-04-2021, 06:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] Load date/time from .txt to 'datetime64' type. water 4 636 Mar-01-2024, 11:16 PM
Last Post: Gribouillis
  Parsing and summing time deltas (duration) onto bar + pie charts using pandas - - DRY Drone4four 2 605 Feb-10-2024, 06:04 PM
Last Post: Drone4four
  Pandas read csv file in 'date/time' chunks MorganSamage 4 1,724 Feb-13-2023, 11:24 AM
Last Post: MorganSamage
  Pandas - compute means per category and time rama27 7 3,543 Nov-13-2020, 08:55 AM
Last Post: PsyPy
  replace nan values by mean group by date.year, date.month wissam1974 5 8,509 Feb-19-2020, 06:25 PM
Last Post: AnkitGupta
  Obtaining Correct Date In Pandas DataFrame eddywinch82 14 6,039 Feb-17-2020, 11:45 AM
Last Post: eddywinch82
  Trying to Pass date to pandas search from input prompt curranjohn46 1 2,124 Oct-10-2019, 10:01 AM
Last Post: curranjohn46
  Need help passing date to pandas query curranjohn46 1 5,488 Oct-10-2019, 09:59 AM
Last Post: curranjohn46
  create 10 yearly blocks from time series using pandas Staph 1 1,977 Jul-23-2019, 12:01 PM
Last Post: Malt
  Pandas converting date to epoch randor 2 3,941 Jul-16-2019, 02:41 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020