用法:
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。