I have this data in Excel File
When read with this logic,
df = pd.read_excel(xls_file_path)
# Convert DataFrame to JSON
json_data = df.to_json(orient='records')
print(json_data)
[{"Name":"Deepak Kalindi","Employee ID":101,"Joining Date":1704153600000,"Leaving Date":null,"Monthly Salary":12000,"Number of full days":27,"Number of half days":2.5,"Number of leaves":1.5,"OT (full Day)":3,"OT (half Day)":2}]
How to get Joining Date as "02-01-2024" in JSON string?
3
Answers
Try this:
Try with
date_format=iso
, see documentationOutput:
Also, you can force your date columns to be string, which will give you the exact output but depending on your end use-case might not be appropriate:
Print:
You can simply use
dt.strftime
:Output: