0

Can we convert the highlighted INTEGER values to STRING value (refer below link)?

https://i.stack.imgur.com/3JbLQ.png

CODE

filename = "newsample2.csv"
jsonFileName = "myjson2.json"


import pandas as pd
df = pd.read_csv ('newsample2.csv')

df.to_json('myjson2.json', indent=4)
print(df)
imkanishks
  • 11
  • 1

1 Answers1

1

Try doing something like this.

import pandas as pd

filename = "newsample2.csv"
jsonFileName = "myjson2.json"
df = pd.read_csv ('newsample2.csv')
df['index'] = df.index
df.to_json('myjson2.json', indent=4)
print(df)

This will take indices of your data and store them in the index column, so they will become a part of your data.

George
  • 151
  • 10