将 json 读入 pandas 数据帧时允许使用哪些类型规范?
What type specs are allowed when reading json into a pandas dataframe?
我想使用 pandas.read_json()
函数将数据导入 pandas 数据框,我将对 orient
参数使用 table
以便能够提供数据类型信息。在这种情况下,输入 json 有一个 schema
属性 可用于指定输入元数据,如下所示:
{
"schema": {
"fields": [
{
"name": "col1",
"type": "integer"
},
{
"name": "col2",
"type": "string"
},
{
"name": "col3",
"type": "integer"
}
],
"primaryKey": [
"col1"
]
},
"data": [...]
}
不过,pandas documentation (section "Encoding with Table Schema") does not elaborate on what kind of type specifications I can use. The "schema" property name suggests that maybe the type specs from json schema都支持吗?任何人都可以确认或以其他方式提供有关支持的类型规格的信息吗?
在 pandas.read_json()
和 Dataframe.to_json()
中都适用于 orient
='table' 的 table 模式被记录在案 here。
我想使用 pandas.read_json()
函数将数据导入 pandas 数据框,我将对 orient
参数使用 table
以便能够提供数据类型信息。在这种情况下,输入 json 有一个 schema
属性 可用于指定输入元数据,如下所示:
{
"schema": {
"fields": [
{
"name": "col1",
"type": "integer"
},
{
"name": "col2",
"type": "string"
},
{
"name": "col3",
"type": "integer"
}
],
"primaryKey": [
"col1"
]
},
"data": [...]
}
不过,pandas documentation (section "Encoding with Table Schema") does not elaborate on what kind of type specifications I can use. The "schema" property name suggests that maybe the type specs from json schema都支持吗?任何人都可以确认或以其他方式提供有关支持的类型规格的信息吗?
在 pandas.read_json()
和 Dataframe.to_json()
中都适用于 orient
='table' 的 table 模式被记录在案 here。