> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/analytics/pandas-format-custom-date-in-data-frame.md).

# pandas format custom date in data frame

say you have a data frame like this

```
[
  {foo: 1, created_date:"2016-06-04 03:00:01.727"},
  ...
]
```

the timestamp doesn't recognize immediately. To make this field as timestamp and as index we could do

```python
# assuming df contains the data frame
df['timestamp'] = pd.to_datetime(be.timestamp, format="%Y-%m-%d %H:%M:%S.%f")
df.set_index(df['timestamp'], inplace=True)
```
