簡體   English   中英

如何用 pandas 讀取孟加拉語 dataframe json 文件

[英]How to read bangla dataframe json file with pandas

這里我的代碼看起來像

import codecs
import pandas as pd
pd.read_json(codecs.open('/content/drive/MyDrive/content_colab_access/quotes_test.json', 'r', 'utf-8'))
print(data.shape)
data.head()

我在 quotes_test.json 中有不同的引號。 這里 dataframe 的一些部分是,

[
    {
      "Quote": "যখন মানুষের খুব প্রিয় কেউ তাকে অপছন্দ করে না",
      "Author": "Humayun Ahmed",
      "Tags": [
        "bangladesh"," bengali"," humayun-ahmed "
      ],
      "Popularity": 0.381,
      "Category": "life"
    }
  ] 

我發現的錯誤,

ValueError: Unexpected character found when decoding array value

所以我想問大家什么是正確的方法? 我想讓 output 像這里 謝謝你。

編碼不是必需的類型。

pd.read_json(codecs.open('/content/drive/MyDrive/content_colab_access/quotes_test.json', 'r', 'utf-8-sig'))

我推薦模塊chardet來檢測編碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM