0

I have a dataset containing userid, ratings, and timestamp information. The 'timestamp' column in the original dataset is of integer datatype and I need to convert it into date data type. My sample dataset is as below:

| userId | rating | timestamp |
|--------|--------|-----------|
| 741    | 3.5    | 40006     |
| 742    | 3.5    | 41707     |
| 741    | 2.5    | 40279     |
| 743    | 3.5    | 41404     |
| 765    | 3.5    | 41684     |
| 800    | 2.5    | 42440     |
| 804    | 3      | 41540     |
| 802    | 4      | 41715     |
| 801    | 2.5    | 39916     |
| 741    | 3.5    | 41707     |

I have tried below line of code but all the timestamps give me one date '1970-01-01'.

df.loc[:,'timestamp'] = pd.to_datetime(df.loc[:,'timestamp'], format='%d%b%Y')

Can someone please let me know what the correction will be?

hk2
  • 487
  • 3
  • 15

0 Answers0