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

Комментарии • 12

  • @higiniofuentes2551
    @higiniofuentes2551 3 месяца назад +1

    Thank you for this very useful video!

  • @karanjugran1997
    @karanjugran1997 Год назад

    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

    • @DataEngUncomplicated
      @DataEngUncomplicated  Год назад

      Thanks Karan I'm glad you found this helpful! Thanks for subscribing!

  • @SaysAnX
    @SaysAnX Год назад +1

    good!!!

  • @chinnu4d464
    @chinnu4d464 Год назад

    Super sir excellent teaching

  • @texasfossilguy
    @texasfossilguy 2 года назад

    you can put the r'f:\ code inside
    df = pd.read_csv(r'f:\ etc) for example no need for two lines of code

    • @DataEngUncomplicated
      @DataEngUncomplicated  2 года назад +1

      Hi Tyler, correct! I tried to make the code more readable for the video so I separated it out.

  • @umaralisiddiqui
    @umaralisiddiqui 2 года назад

    Hey, I'm getting this erro while converting to json please tell!
    TypeError: to_json() got an unexpected keyword argument 'indent'

    • @DataEngUncomplicated
      @DataEngUncomplicated  2 года назад

      Hi Umar, it sounds like you have an invalid parameter that you passed

    • @umaralisiddiqui
      @umaralisiddiqui 2 года назад

      @@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.