Date time Flashcards

1
Q

If you want to combine columns to have dates how do you do it?

A

pd.read_csv(url, parse_dates = [[0,1,2]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When the index is a date, how do you select different dates?

A

df. loc(‘1996-08-01’)

df. index.month == 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If you want to convert to datetime format how do you do it?

A

1) parse dates when importing

2) . pd.to_datetime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Alias for year end?

A

A, Y

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Alias for year start?

A

AS, YS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Alias for weekly

A

W

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Alias for month end?

A

M

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Alias for month start?

A

MS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Alias for business mont end/

A

BM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Alias for quarter?

A

Q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Alias for business quarter end

A

BQ

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you get isoformat dates?

A

datename.isoformat()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the method for converting a date into a string?

A

strftime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you get the month fully written out?

A

strftime(‘%B’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you change bits of a datetime format?

A

dt.replace(minutes = 12)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you output datetime as strings?

A

variablenamehere.strftime(‘%Y’)

17
Q

How do you parse strings as datetime?

A

datetime.strptime(‘string in here’, ‘%Y’)

18
Q

What is the syntax for strftime?

A

variancename.strftime(‘%Y’)

19
Q

What is the syntax for strptime?

A

datetime.strptime(‘string’,’%y’)

20
Q

Which one has to have datetime in front?

A

datetime. strptime

variablename. strftime

21
Q

How do you get a timezone stored?

A

timezone(timedelta(hours = -5))

22
Q

When do you use replace and when do you use astimezone?

A

astimezone actually changes the stored time

replace just changes the offset

23
Q

How do you change the timezone?

A

variable.astimezone(timezone)

24
Q

How do you get timezones?

A

tz.gettz(‘Continent/City’)

25
Q

What is the module for getting timezones

A

from dateutil import tz

26
Q

How do you deal with daylight saving time?

A

Convert everything to UTC

27
Q

How do you get the duration between times as a number rather than a timedelta?

A

total_seconds()