pd.datetime notebook

import pandas as pd
df = pd.read_csv('../data/spotify_dataset.csv', na_values = " ")
df["Release Date"]
0       2017-12-08
1       2021-07-09
2       2021-05-21
3       2021-06-25
4       2021-07-23
           ...    
1551    2017-06-02
1552    2019-10-11
1553    2018-01-12
1554    2019-09-25
1555    2019-11-13
Name: Release Date, Length: 1556, dtype: object
pd.to_datetime(df["Release Date"])
0      2017-12-08
1      2021-07-09
2      2021-05-21
3      2021-06-25
4      2021-07-23
          ...    
1551   2017-06-02
1552   2019-10-11
1553   2018-01-12
1554   2019-09-25
1555   2019-11-13
Name: Release Date, Length: 1556, dtype: datetime64[ns]
df.dtypes
Index                          int64
Highest Charting Position      int64
Number of Times Charted        int64
Week of Highest Charting      object
Song Name                     object
Streams                       object
Artist                        object
Artist Followers             float64
Song ID                       object
Genre                         object
Release Date                  object
Weeks Charted                 object
Popularity                   float64
Danceability                 float64
Energy                       float64
Loudness                     float64
Speechiness                  float64
Acousticness                 float64
Liveness                     float64
Tempo                        float64
Duration (ms)                float64
Valence                      float64
Chord                         object
dtype: object
df["Release Date"] = pd.to_datetime(df["Release Date"])
df.dtypes
Index                                 int64
Highest Charting Position             int64
Number of Times Charted               int64
Week of Highest Charting             object
Song Name                            object
Streams                              object
Artist                               object
Artist Followers                    float64
Song ID                              object
Genre                                object
Release Date                 datetime64[ns]
Weeks Charted                        object
Popularity                          float64
Danceability                        float64
Energy                              float64
Loudness                            float64
Speechiness                         float64
Acousticness                        float64
Liveness                            float64
Tempo                               float64
Duration (ms)                       float64
Valence                             float64
Chord                                object
dtype: object
df.loc[3,"Release Date"].day_name()
'Friday'
df.loc[3,"Release Date"].month_name()
'June'
df["Release Date"].map(lambda d: d.day_name())
0          Friday
1          Friday
2          Friday
3          Friday
4          Friday
          ...    
1551       Friday
1552       Friday
1553       Friday
1554    Wednesday
1555    Wednesday
Name: Release Date, Length: 1556, dtype: object
df[df["Release Date"].map(lambda d: d.day_name()) == "Tuesday"]
Index Highest Charting Position Number of Times Charted Week of Highest Charting Song Name Streams Artist Artist Followers Song ID Genre ... Danceability Energy Loudness Speechiness Acousticness Liveness Tempo Duration (ms) Valence Chord
48 49 29 6 2021-06-25--2021-07-02 Fiel - Remix 10,032,746 Wisin, Jhay Cortez, Anuel AA, Los Legendarios,... 6929075.0 43qcs9NpJhDxtG91zxFkj7 ['latin', 'latin hip hop', 'reggaeton', 'trap ... ... 0.839 0.711 -4.733 0.0473 0.398000 0.1180 97.990 349547.0 0.5730 F#/Gb
56 57 57 5 2021-07-23--2021-07-30 Meu Pedaço de Pecado 9,206,366 João Gomes 409173.0 2kJRlOyrxsy7Ot3c5TZ8Q6 [] ... 0.668 0.887 -4.404 0.0564 0.369000 0.2570 151.920 157176.0 0.9070 B
94 95 75 10 2021-07-02--2021-07-09 Ram Pam Pam 7,064,003 Natti Natasha, Becky G 6341942.0 4DHDIdeayp8xvlyg22wREO ['latin', 'latin pop', 'rap latina', 'reggaeto... ... 0.908 0.813 -2.749 0.0777 0.305000 0.2780 97.018 200785.0 0.9240 F
97 98 60 8 2021-06-18--2021-06-25 t r a n s p a r e n t s o u l feat. Travis Barker 6,853,994 WILLOW 1521837.0 1QL7nSDZCwZMnbisV4KOXt ['afrofuturism', 'dance pop', 'electropop', 'p... ... 0.390 0.830 -5.201 0.0563 0.002100 0.1560 90.021 168030.0 0.1910 B
105 106 45 19 2021-04-30--2021-05-07 Talking to the Moon 6,660,319 Bruno Mars 32574754.0 161DnLWsx1i3u1JT05lzqU ['dance pop', 'pop', 'post-teen pop'] ... 0.523 0.606 -4.754 0.0301 0.512000 0.1060 145.837 217867.0 0.0650 C#/Db
126 127 122 37 2021-07-16--2021-07-23 Riptide 6,089,242 Vance Joy 2421254.0 3JvrhDOgAt6p7K8mDyZwRd ['folk-pop', 'modern rock', 'pop', 'pop rock'] ... 0.484 0.731 -6.694 0.0379 0.431000 0.1510 101.654 204280.0 0.5100 C#/Db
130 131 131 3 2021-07-23--2021-07-30 Aquelas Coisas 6,012,839 João Gomes 409173.0 0FqVtQxRD3HsPltldG5v5M [] ... 0.682 0.873 -4.163 0.0449 0.402000 0.0946 150.006 147072.0 0.9640 F#/Gb
133 134 76 16 2021-04-23--2021-04-30 Another Love 5,914,661 Tom Odell 1838616.0 7otCGmgp9h4CsR2LhwB6gt ['pop'] ... 0.445 0.537 -8.532 0.0400 0.695000 0.0941 122.764 244360.0 0.1310 E
152 153 153 1 2021-07-23--2021-07-30 Como Si No Importara 5,627,257 Emilia, Duki 205590.0 1GYJpuLq41vEVKXiHGEY9j [] ... 0.843 0.534 -6.658 0.1420 0.467000 0.0984 94.984 173053.0 0.5280 C#/Db
153 154 154 1 2021-07-23--2021-07-30 Se For Amor 5,618,268 João Gomes, Vitor Fernandes 409173.0 5F2xRvRFkxDvqdFtUNAEyw [] ... 0.667 0.899 -4.402 0.0322 0.423000 0.3320 147.962 239928.0 0.8350 B
154 155 142 23 2021-05-28--2021-06-04 Wake Me Up 5,607,285 Avicii 20270895.0 0nrRP2bk19rLc0orkWPQk2 ['dance pop', 'edm', 'pop', 'pop dance'] ... 0.532 0.783 -5.697 0.0523 0.003800 0.1610 124.080 247427.0 0.6430 D
169 170 155 22 2021-07-02--2021-07-09 Mr. Brightside 5,382,191 The Killers 6118063.0 7oK9VyNzrYvRFo7nQEYkWN ['dance rock', 'modern rock', 'permanent wave'... ... 0.356 0.924 -3.740 0.0808 0.001010 0.0953 148.017 222587.0 0.2320 C#/Db
191 192 64 3 2021-07-09--2021-07-16 De Museo 5,016,125 Bad Bunny 36142273.0 267NGliXM8YLVZiKAD9Otm ['latin', 'reggaeton', 'trap latino'] ... 0.592 0.494 -10.618 0.0747 0.237000 0.1300 132.037 209771.0 0.2310 E
199 200 172 12 2021-05-28--2021-06-04 The Real Slim Shady 4,948,965 Eminem 46785561.0 3yfqSUWxFvZELEM4PmlwIR ['detroit hip hop', 'hip hop', 'rap'] ... 0.949 0.661 -4.244 0.0572 0.030200 0.0454 104.504 284200.0 0.7600 F
284 285 170 13 2021-04-23--2021-04-30 Can't Hold Us - feat. Ray Dalton 5,085,147 Macklemore & Ryan Lewis 2562082.0 3bidbhpOYeV4knp8AIu8Xn ['modern rock', 'pop rap', 'seattle hip hop'] ... 0.641 0.922 -4.457 0.0786 0.029100 0.0862 146.078 258343.0 0.8470 D
287 288 133 20 2021-04-30--2021-05-07 Just the Way You Are 5,043,647 Bruno Mars 32574754.0 7BqBn9nzAq8spo5e7cZ0dJ ['dance pop', 'pop', 'post-teen pop'] ... 0.637 0.843 -5.413 0.0432 0.015100 0.0876 109.012 220733.0 0.4340 F
293 294 176 6 2020-10-09--2020-10-16 In the End 4,910,070 Linkin Park 19584111.0 60a0Rd6pjrkxjPbaKzXjfq ['alternative metal', 'nu metal', 'post-grunge... ... 0.556 0.864 -5.870 0.0584 0.009580 0.2090 105.143 216880.0 0.4000 D#/Eb
294 295 119 6 2021-05-14--2021-05-21 No Role Modelz 4,904,401 J. Cole 14097410.0 62vpWI1CHwFy7tMIcSStl8 ['conscious hip hop', 'hip hop', 'north caroli... ... 0.692 0.521 -8.465 0.3300 0.301000 0.0565 100.450 292987.0 0.4630 A#/Bb
369 370 182 5 2021-05-14--2021-05-21 Explícito 5,278,449 Myke Towers 6150675.0 6qraVL4IJaIj0IuEexYJNa ['trap latino'] ... 0.828 0.830 -3.371 0.0470 0.348000 0.0613 95.007 195066.0 0.4220 D
373 374 77 10 2021-03-26--2021-04-02 Cupid's Chokehold / Breakfast in America 5,165,035 Gym Class Heroes 1275345.0 2Lhdl74nwwVGOE2Gv35QuK ['dance pop', 'pop rap'] ... 0.720 0.744 -6.938 0.1200 0.237000 0.2550 78.953 243773.0 0.6190 C#/Db
378 379 169 1 2021-05-07--2021-05-14 What You Need 5,346,005 Don Toliver 1605329.0 6LcX2hBbXaJcK4AuefE936 ['rap', 'trap'] ... 0.664 0.655 -7.327 0.0461 0.059000 0.1700 129.987 217609.0 0.1300 A#/Bb
391 392 53 12 2021-03-12--2021-03-19 SugarCrash! 5,018,005 ElyOtto 85617.0 2ePtv8MlBO9nuuXABqAfEX ['weirdcore'] ... 0.748 0.734 -6.499 0.1240 0.524000 0.0975 97.753 80081.0 0.3680 C
430 431 68 1 2021-04-09--2021-04-16 X Gon' Give It To Ya 8,638,360 DMX 2815928.0 1zzxoZVylsna2BQB65Ppcb ['east coast hip hop', 'gangster rap', 'hardco... ... 0.761 0.899 -3.090 0.1830 0.013500 0.0719 95.027 217587.0 0.6730 A#/Bb
455 456 120 15 2021-03-05--2021-03-12 Hayloft 5,086,382 Mother Mother 2110870.0 2kS6td1yvmpNgZTt1q5pQq ['indie pop', 'vancouver indie'] ... 0.527 0.922 -2.666 0.0728 0.004750 0.4220 95.975 181680.0 0.4900 A
471 472 181 1 2021-03-26--2021-04-02 Girls Like Us 5,410,730 Zoe Wees 203555.0 5SFXOMJJ334Wn2PwBHeRZN ['german pop'] ... 0.444 0.648 -4.955 0.0476 0.288000 0.0590 125.706 189000.0 0.1710 C#/Db
551 552 9 46 2020-06-05--2020-06-12 ily (i love you baby) (feat. Emilee) 4,908,929 Surf Mesa 132855.0 62aP9fBQKYKxi7PDXwcUAS ['tropical house'] ... 0.674 0.774 -7.567 0.0892 0.068600 0.3930 112.050 176547.0 0.3300 B
564 565 162 3 2021-01-29--2021-02-05 Mds 5,046,418 Kawe, Mc Lele JP 444736.0 0QglpM23kl9ldvVdoYNZwF ['brazilian hip hop', 'funk ostentacao'] ... 0.885 0.561 -5.331 0.2490 0.261000 0.1210 140.020 125143.0 0.6440 F#/Gb
587 588 73 6 2020-12-11--2020-12-18 Reminds Me Of You 5,942,551 Juice WRLD, The Kid LAROI 19102888.0 5YSHygGN9D0mID1NsVd5my ['chicago rap', 'melodic rap'] ... 0.613 0.631 -6.965 0.1200 0.066300 0.1690 149.992 158033.0 0.3300 E
619 620 1 10 2020-12-18--2020-12-25 All I Want for Christmas Is You 23,235,257 Mariah Carey 6931357.0 0bYg9bo50gSsH3LtXe2SQn ['dance pop', 'pop', 'r&b', 'urban contemporary'] ... 0.336 0.627 -7.463 0.0384 0.164000 0.0708 150.273 241107.0 0.3500 G
626 627 9 7 2020-12-18--2020-12-25 Underneath the Tree 12,266,990 Kelly Clarkson 7869617.0 3YZE5qDV7u1ZD1gZc47ZeR ['dance pop', 'neo mellow', 'pop', 'pop rock',... ... 0.509 0.812 -5.439 0.0537 0.001280 0.2140 159.878 229640.0 0.6890 G#/Ab
627 628 14 6 2020-12-18--2020-12-25 Feliz Navidad 11,664,490 José Feliciano 239129.0 0oPdaY4dXtc3ZsaG17V972 ['latin pop', 'puerto rican pop'] ... 0.513 0.831 -9.004 0.0383 0.550000 0.3360 148.837 182067.0 0.9630 D
629 630 19 6 2020-12-18--2020-12-25 Let It Snow! Let It Snow! Let It Snow! (with T... 10,787,165 Frank Sinatra 4953667.0 4kKdvXD0ez7jp1296JmAts ['adult standards', 'easy listening', 'lounge'] ... 0.652 0.259 -13.336 0.0595 0.903000 0.3620 142.169 155453.0 0.8360 D
631 632 16 6 2020-12-18--2020-12-25 Sleigh Ride 10,508,459 The Ronettes 1251372.0 5ASM6Qjiav2xPe7gRkQMsQ [] ... 0.529 0.772 -7.013 0.0287 0.403000 0.3160 91.751 181267.0 0.8530 D
635 636 24 5 2020-12-18--2020-12-25 Happy Xmas (War Is Over) - Remastered 2010 9,509,781 John Lennon, Yoko Ono 4313100.0 27RYrbL6S02LNVhDWVl38b ['album rock', 'art rock', 'beatlesque', 'clas... ... 0.321 0.640 -10.023 0.0324 0.280000 0.7180 146.172 214333.0 0.4140 D
643 644 62 4 2020-12-18--2020-12-25 Blue Christmas 6,007,011 Elvis Presley 5698788.0 3QiAAp20rPC3dcAtKtMaqQ ['rock-and-roll', 'rockabilly'] ... 0.465 0.270 -16.661 0.0425 0.900000 0.1450 94.518 129173.0 0.5800 E
646 647 52 5 2020-12-18--2020-12-25 Santa Baby 5,687,085 Kylie Minogue 1324920.0 0cM5URUqqQTpJWonmdzF1J ['australian dance', 'australian pop', 'dance ... ... 0.685 0.391 -7.183 0.0435 0.744000 0.1420 87.101 202547.0 0.4430 C#/Db
648 649 69 6 2020-12-18--2020-12-25 Christmas (Baby Please Come Home) 5,394,054 Darlene Love 1251372.0 46pF1zFimM582ss1PrMy68 [] ... 0.325 0.759 -7.146 0.0530 0.395000 0.0773 126.627 166453.0 0.3600 G#/Ab
653 654 71 3 2020-12-18--2020-12-25 Jingle Bell Rock - Daryl's Version 10,522,305 Daryl Hall & John Oates 1549216.0 6pVW5LRWgeLaHudxauOTJU ['album rock', 'classic rock', 'mellow gold', ... ... 0.666 0.841 -3.592 0.0312 0.613000 0.1130 128.706 126360.0 0.8400 D
658 659 86 2 2020-12-18--2020-12-25 My Only Wish (This Year) 9,457,199 Britney Spears 9470311.0 0YWUHZPJVg4iujddsJDwhM ['dance pop', 'pop', 'post-teen pop'] ... 0.669 0.843 -3.766 0.0268 0.169000 0.1950 147.080 255400.0 0.7020 C
669 670 126 1 2020-12-18--2020-12-25 Santa Baby (with Henri René & His Orchestra) 8,022,773 Eartha Kitt, Henri Rene & His Orchestra 127251.0 1foCxQtxBweJtZmdxhEHVO ['adult standards', 'lounge', 'torch song', 'v... ... 0.700 0.139 -12.346 0.0607 0.902000 0.1850 84.485 206067.0 0.4900 G#/Ab
686 687 175 1 2020-12-18--2020-12-25 This Christmas 6,809,438 Donny Hathaway 424935.0 38xhBO2AKrJnjdjVnhJES6 ['chicago soul', 'classic soul', 'funk', 'moto... ... 0.634 0.645 -9.200 0.0376 0.292000 0.2460 93.047 231173.0 0.6770 F
687 688 180 1 2020-12-18--2020-12-25 Winter Wonderland 6,680,928 Tony Bennett 659472.0 6kkJlaBYdyFcwCg67hW40t ['adult standards', 'easy listening', 'lounge'... ... 0.604 0.497 -6.676 0.0319 0.727000 0.1020 126.011 149307.0 0.7200 C#/Db
740 741 151 5 2020-10-02--2020-10-09 Heart Of Glass (Live from the iHeart Festival) 6,006,877 Miley Cyrus 15778531.0 5i7ThJfYLAzp2DyZuFpF6j ['dance pop', 'pop', 'post-teen pop'] ... 0.580 0.908 -5.303 0.0341 0.000335 0.0870 115.016 213672.0 0.4270 E
764 765 9 28 2020-06-12--2020-06-19 Party Girl 4,878,286 StaySolidRocky 150587.0 5RqR4ZCCKJDcBLIn4sih9l ['melodic rap'] ... 0.728 0.431 -9.966 0.0622 0.749000 0.0996 130.022 147800.0 0.6290 F#/Gb
774 775 144 4 2020-10-23--2020-10-30 Blueberry Eyes (feat. SUGA of BTS) 5,158,896 MAX 689627.0 5dn6QANKbf76pANGjMBida ['dance pop', 'electropop', 'pop', 'pop rap', ... ... 0.746 0.611 -7.034 0.1010 0.454000 0.1330 149.967 172245.0 0.4110 C
820 821 137 2 2020-10-16--2020-10-23 Fake 5,010,179 Lauv, Conan Gray 4442273.0 4Gt2kh3QbAGU6yquOWn4aW ['dance pop', 'electropop', 'pop', 'post-teen ... ... 0.703 0.657 -5.363 0.0783 0.139000 0.0930 82.960 146375.0 0.4550 E
843 844 46 2 2020-10-02--2020-10-09 You Never Know 5,304,382 BLACKPINK 23848461.0 3b7trEcKoglybN5MxGuSaw ['k-pop', 'k-pop girl group'] ... 0.535 0.434 -5.768 0.0505 0.405000 0.2530 144.497 229236.0 0.2710 F
848 849 110 12 2020-09-04--2020-09-11 Oh Juliana 4,751,064 Niack 352402.0 4xWzZmX4K1yyrdtRfbUvjt ['funk carioca'] ... 0.799 0.568 -3.089 0.2500 0.387000 0.0892 129.630 153078.0 0.9630 F#/Gb
945 946 72 4 2020-06-19--2020-06-26 Stay Gold 4,405,338 BTS 37151476.0 3Ys2PYl1wyPKQIwyqhP9cQ ['k-pop', 'k-pop boy group'] ... 0.723 0.634 -5.415 0.0542 0.089200 0.0787 129.017 243267.0 0.5820 C#/Db
969 970 157 1 2020-08-07--2020-08-14 BLIND (feat. Young Thug) 5,074,613 DaBaby 7601122.0 2T5NBwKRySiCR78vVk08vr ['north carolina hip hop', 'rap'] ... 0.709 0.679 -6.503 0.3460 0.011500 0.0971 162.973 153467.0 0.7540 B
1033 1034 57 3 2020-07-03--2020-07-10 Wash Us In The Blood 5,586,085 Kanye West, Travis Scott 14624703.0 7mEUjhl6aTztdHCrxoTgBG ['chicago rap', 'rap'] ... 0.670 0.847 -4.850 0.4090 0.184000 0.3040 137.220 189827.0 0.3810 A#/Bb
1075 1076 189 1 2020-06-26--2020-07-03 Karaoke 4,374,448 Boomdabash, Alessandra Amoroso 1251372.0 3n6TeHSnNhDe991nJS2S90 [] ... 0.929 0.625 -5.728 0.1400 0.289000 0.3860 122.030 156493.0 0.5780 C#/Db
1076 1077 36 21 2020-02-07--2020-02-14 Know Your Worth 4,374,392 Khalid, Disclosure 14190858.0 0TrPqhAMoaKUFLR7iYDokf ['pop'] ... 0.790 0.694 -7.726 0.0708 0.145000 0.2810 103.007 181436.0 0.5080 A
1089 1090 134 1 2020-06-19--2020-06-26 Snow On Tha Bluff 5,060,764 J. Cole 14103694.0 1oOEkBNp4zWnkD7nWjJdog ['conscious hip hop', 'hip hop', 'north caroli... ... 0.586 0.512 -8.819 0.0668 0.723000 0.1190 75.857 235480.0 0.2350 G#/Ab
1094 1095 145 5 2020-06-05--2020-06-12 IDK You Yet 4,473,413 Alexander 23 207170.0 0j1Ia2lQWrcXrQZI4AdJlk ['alt z', 'indie cafe pop', 'pop', 'post-teen ... ... 0.648 0.308 -11.729 0.0400 0.886000 0.1240 76.997 184638.0 0.1980 C#/Db
1105 1106 154 6 2020-06-05--2020-06-12 Surrender 4,627,942 Natalie Taylor 120208.0 0ecC8p17cDNlxHXkuYqeR6 [] ... 0.390 0.448 -8.570 0.0276 0.800000 0.1070 144.890 183103.0 0.0770 F
1238 1239 156 13 2020-01-31--2020-02-07 3 Nights 4,411,998 Dominic Fike 554042.0 1tNJrcVe6gwLEiZCtprs1u ['alternative pop rock', 'pop'] ... 0.815 0.518 -6.594 0.0897 0.223000 0.1040 151.891 177667.0 0.8770 G
1392 1393 129 3 2020-02-07--2020-02-14 Lose Yourself - From "8 Mile" Soundtrack 5,118,004 Eminem 46814751.0 5Z01UMMf7V1o0MzF86s6WJ ['detroit hip hop', 'hip hop', 'rap'] ... 0.692 0.744 -4.565 0.2570 0.008680 0.3590 171.374 326467.0 0.0612 D
1420 1421 80 4 2020-01-24--2020-01-31 Forever Yours - Avicii Tribute 5,421,905 Kygo, Sandro Cavazza 1251372.0 418ohXmKnlngIosIn6gG0H [] ... 0.530 0.612 -8.794 0.0518 0.253000 0.2460 119.255 193847.0 0.4330 A#/Bb
1432 1433 66 7 2020-01-03--2020-01-10 Yellow Hearts 6,554,824 Ant Saunders 82522.0 2W4yABdLc4Jnds67Poi5Nl ['chill r&b', 'pop'] ... 0.866 0.438 -8.943 0.0719 0.177000 0.0743 129.039 223258.0 0.6950 G

60 rows × 23 columns

df[df["Release Date"].map(lambda d: d.day_name()) == "Tuesday"].shape
(60, 23)