用法:
pandas.io.json.build_table_schema(data, index=True, primary_key=None, version=True)
从
data
创建表架构。- data:系列, DataFrame
- index:布尔值,默认为真
是否在架构中包含
data.index
。- primary_key:bool 或 None,默认为 True
要指定为主键的列名。如果索引是唯一的,默认
None
会将‘primaryKey’
设置为索引级别。- version:布尔值,默认为真
是否包含字段
pandas_version
以及上次修改表模式的 pandas 版本。此版本可能与已安装的 pandas 版本不同。
- schema:dict
参数:
返回:
注意:
有关转换类型,请参见表架构。 Timedeltas 转换为 ISO8601 持续时间格式,秒字段后有 9 位小数,以实现纳秒精度。
分类将转换为
any
dtype,并使用enum
字段约束列出允许的值。ordered
属性包含在ordered
字段中。例子:
>>> df = pd.DataFrame( ... {'A':[1, 2, 3], ... 'B':['a', 'b', 'c'], ... 'C':pd.date_range('2016-01-01', freq='d', periods=3), ... }, index=pd.Index(range(3), name='idx')) >>> build_table_schema(df) {'fields':[{'name':'idx', 'type':'integer'}, {'name':'A', 'type':'integer'}, {'name':'B', 'type':'string'}, {'name':'C', 'type':'datetime'}], 'primaryKey':['idx'], 'pandas_version':'1.4.0'}
相关用法
- Python pandas.io.formats.style.Styler.format_index用法及代码示例
- Python pandas.io.formats.style.Styler.text_gradient用法及代码示例
- Python pandas.io.formats.style.Styler.hide用法及代码示例
- Python pandas.io.formats.style.Styler.set_table_attributes用法及代码示例
- Python pandas.io.formats.style.Styler.set_tooltips用法及代码示例
- Python pandas.io.formats.style.Styler.set_properties用法及代码示例
- Python pandas.io.formats.style.Styler.apply_index用法及代码示例
- Python pandas.io.formats.style.Styler.set_td_classes用法及代码示例
- Python pandas.io.formats.style.Styler.to_latex用法及代码示例
- Python pandas.io.formats.style.Styler.pipe用法及代码示例
- Python pandas.io.formats.style.Styler.where用法及代码示例
- Python pandas.io.formats.style.Styler.format用法及代码示例
- Python pandas.io.formats.style.Styler.highlight_between用法及代码示例
- Python pandas.io.formats.style.Styler.use用法及代码示例
- Python pandas.io.formats.style.Styler.applymap用法及代码示例
- Python pandas.io.formats.style.Styler.applymap_index用法及代码示例
- Python pandas.io.formats.style.Styler.background_gradient用法及代码示例
- Python pandas.io.formats.style.Styler.to_excel用法及代码示例
- Python pandas.io.formats.style.Styler.highlight_quantile用法及代码示例
- Python pandas.io.formats.style.Styler.export用法及代码示例
注:本文由纯净天空筛选整理自pandas.pydata.org大神的英文原创作品 pandas.io.json.build_table_schema。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。