I have this dataset:

| date\_time | srch\_id |  |  |
| --- | --- | --- | --- |
| 2013-04-04 08:32:15 | 1 |  |  |
| 2013-04-04 08:32:15 | 1 |  |  |
| .. |  |  |  |
| 2013-06-30 19:55:18 | 332785 |  |  |
| 2013-06-30 19:55:18 | 332785 |  |  |

And I want to separate date\_time into: YM (Year\_Month),YMQ(Year\_Month\_Quarter),Y and M:

| date\_time | srch\_id | YMQ | YM | Y | M |
| --- | --- | --- | --- | --- | --- |
| 2013-04-04 08:32:15 | 1 | 2013-04-2 | 2013-04 | 2013 | 4 |
| 2013-04-04 08:32:15 | 1 | 2013-04-2 | 2013-04 | 2013 | 4 |
| .. |  |  |  |  |  |
| 2013-06-30 19:55:18 | 332785 | 2013-06-2 | 2013-04 | 2013 | 6 |
| 2013-06-30 19:55:18 | 332785 | 2013-06-2 | 2013-04 | 2013 | 6 |

I already succeeded with separating it with YM,Y and M with this code:

```
list_YM = [i.split(" ")[0][:-3] for i in  list(train_dataset['date_time'])]
list_Year = [i.split(" ")[0][0:4] for i in  list(train_dataset['date_time'])]
list_Month = [i.split(" ")[0][5:7] for i in  list(train_dataset['date_time'])]

train_dataset['YM'] = list_YM
train_dataset['Year'] = list_Year
train_dataset['Month'] = list_Month

```

But how do I get YMQ and Q?