CSV To JSON With Python Pandas
HTML-код
- Опубликовано: 26 июл 2024
- #pandas, #python,
Step by step guide on how to read in a csv file that is comma separated and convert it to a json file. I also cover how to convert a csv file with compression I walk through the various parameters in the to_json method that you should be looking out for when writing your data. Finally, this video ends with how to read back a json file into python with pandas and without.
timestamps
00:00 introduction
00:20 read csv file
02:38 convert pandas dataframe to json
04:44 convert pandas dataframe to compressed json
05:48 read json with pandas
06:25 read compressed gzip in python
Thank you for this very useful video!
You're welcome!
Bro you nailed it specially converting df to json and passing indent and Orient inside to json method.. I was stuck bec my json was reading the row indexes as well and I am new to python this helped me to make a very neat json. Subscribed to the channel keep doing the good work
Thanks Karan I'm glad you found this helpful! Thanks for subscribing!
good!!!
Super sir excellent teaching
Thanks! Much appreciated!
you can put the r'f:\ code inside
df = pd.read_csv(r'f:\ etc) for example no need for two lines of code
Hi Tyler, correct! I tried to make the code more readable for the video so I separated it out.
Hey, I'm getting this erro while converting to json please tell!
TypeError: to_json() got an unexpected keyword argument 'indent'
Hi Umar, it sounds like you have an invalid parameter that you passed
@@DataEngUncomplicated I passed all the parameters as you mentioned in the video. My CSV did get convert to JSON but it wasn't in as formats as yours because of this indent error.