如何在不使用 pandas 数据框的情况下将列名添加到 ipysheet?

How to add column names to ipysheet without using pandas data frame?

这里我们默认获取A,B作为列名,如何覆盖列名并编写我们自己的列名

import ipysheet
from ipysheet import sheet, cell
sheet1 = sheet()
cell(0,0,10);
cell(1,1,100);
cell(2,2,1000);
cell(3,3,"Hello");
sheet1

据我所知,你不能那样做。 ipysheet 不是 pandas 的替代品,它是为 运行 在 jupyter 中设计的电子表格包。就像真正的电子表格一样,您无法更改列标题 ,因为这是您引用事物的方式。但是,就像在真实的电子表格中一样,您可以 在列顶部的 单元格 中放置一个标题。你甚至可以让它脱颖而出,成为 'heading'.

如果您不想在 jupyter notebook 中显示您的数据,您可能不需要 ipysheet。

参考资料

https://github.com/QuantStack/ipysheet

您可以在创建 sheet 时为它编写自己的列名。您可以为此使用 column_headers 参数。

你的情况:

import ipysheet
from ipysheet import sheet, cell
sheet1 = sheet(column_headers=["Not A", "Not B"])
cell(0,0,10);
cell(1,1,100);
cell(2,2,1000);
cell(3,3,"Hello");
sheet1