Good Morning ! I have a dataframe where the data source is a MongoDB JSON:
+---------------------------------------------------+--------------------+
| Id|Data |
+---------------------------------------------------+--------------------+
|{"𝑏𝑖𝑛𝑎𝑟𝑦":"7𝐾𝑔𝑅𝑄𝐾𝑎𝑏𝑞𝑘𝑢𝑥𝐸+1𝑝𝑆𝑤9𝑏7𝑄==","type":"03"} | 1651374000000|
|{"𝑏𝑖𝑛𝑎𝑟𝑦":"𝐻𝑡𝐼𝑂6𝑄/𝐺𝐿𝐸𝐺𝐷𝐵𝑑𝑡𝑊𝑑𝑑𝑝6𝑋𝑔==","type":"03"} | 1622419200000|
|{"𝑏𝑖𝑛𝑎𝑟𝑦":"𝑣𝑝𝑈𝑇𝑒𝑢𝑣𝑒𝐷0𝐺𝐿𝑚𝑙𝑟𝑧𝑗𝑏ℎ𝑖𝐵𝑔==","type":"03"} | 1622419200000|
|{"𝑏𝑖𝑛𝑎𝑟𝑦":"𝑆6𝑗𝑧𝐷𝐸𝑖𝐺𝑥𝑈22𝑂𝑏𝑅𝑉1/𝑁𝑔2𝑄==","type":"03"} | 1622419200000|
+---------------------------------------------------+--------------------+
I need to convert the data to:
+--------------------------------------+--------------------+
| Id |Data |
+--------------------------------------+--------------------+
| 401148EE-9BA6-4BAA-B113-ED694B0F5BED | 2022-05-01 03:00:00|
| E90ED21E-C60F-412C-8305-DB5675DA7A5E | 2021-05-31 00:00:00|
| 7A1395BE-DEEB-410F-8B9A-5AF38DB86206 | 2021-05-31 00:00:00|
| 0CF3A84B-8648-4DC5-B639-B455D7F360D9 | 2021-05-31 00:00:00|
+--------------------------------------+--------------------+
In Python, it is possible to convert the information with the code below:
id_bin = 'S6jzDEiGxU22ObRV1/Ng2Q=='
message_bytes = base64.b64decode(id_bin)
id = uuid.UUID(bytes_le=message_bytes)
data = (1622419200000 // 1000)
date_conv = datetime.datetime.utcfromtimestamp(data).strftime('%Y-%m-%d %H:%M:%S')
pyspark running in a column of a dataframe does not work, can you help me?