1- Working with Pandas and NumPy
1+ 与 Pandas 和 NumPy 一起使用
22=============================
33
4- openpyxl is able to work with the popular libraries `Pandas
5- <http://pandas.pydata.org> `_ and `NumPy <http://numpy.org >`_
4+ openpyxl 可以与流行的 `Pandas <http://pandas.pydata.org >`_ 和 `NumPy <http://numpy.org >`_ 一起使用
65
76
8- NumPy Support
7+ NumPy 支持
98-------------
109
11- openpyxl has builtin support for the NumPy types float, integer and boolean.
10+ openpyxl 内置支持 NumPy 的float, integer 和 boolean 类型。
1211DateTimes are supported using the Pandas' Timestamp type.
1312
1413
15- Working with Pandas Dataframes
14+ 和 Pandas Dataframes 一起使用
1615------------------------------
1716
18- The :func: `openpyxl.utils.dataframe.dataframe_to_rows ` function provides a
19- simple way to work with Pandas Dataframes::
17+ :func: `openpyxl.utils.dataframe.dataframe_to_rows ` 提供了一种使用 Pandas Dataframes 的简单方法::
2018
2119 from openpyxl.utils.dataframe import dataframe_to_rows
2220 wb = Workbook()
@@ -26,11 +24,9 @@ simple way to work with Pandas Dataframes::
2624 ws.append(r)
2725
2826
29- While Pandas itself supports conversion to Excel, this gives client code
30- additional flexibility including the ability to stream dataframes straight to
31- files.
27+ 虽然Pandas本身支持对Excel的转换,但这为客户端代码提供了更多的灵活性,包括直接将数据帧(stream dataframes)流传输到文件的能力。
3228
33- To convert a dataframe into a worksheet highlighting the header and index ::
29+ 将 dataframe 转换为工作簿时高亮表头和索引 ::
3430
3531 wb = Workbook()
3632 ws = wb.active
@@ -43,7 +39,7 @@ To convert a dataframe into a worksheet highlighting the header and index::
4339
4440 wb.save("pandas_openpyxl.xlsx")
4541
46- Alternatively, if you just want to convert the data you can use write-only mode ::
42+ 另外,如果你只想转换数据,你可以使用只写模式 ::
4743
4844 from openpyxl.cell.cell import WriteOnlyCell
4945 wb = Workbook(write_only=True)
@@ -71,19 +67,17 @@ Alternatively, if you just want to convert the data you can use write-only mode:
7167 wb.save("openpyxl_stream.xlsx")
7268
7369
74- This code will work just as well with a standard workbook.
70+ 此代码和标准工作簿一起起作用。
7571
7672
77- Converting a worksheet to a Dataframe
73+ 将工作簿转换为 Dataframe(PS:样例文件可以参考df.to_excel()的文件)
7874-------------------------------------
7975
80- To convert a worksheet to a Dataframe you can use the `values ` property. This
81- is very easy if the worksheet has no headers or indices::
76+ 如果工作簿没有表头和索引很容易用 `values ` 属性将一个工作簿转换为 Dataframe::
8277
8378 df = DataFrame(ws.values)
8479
85- If the worksheet does have headers or indices, such as one created by Pandas,
86- then a little more work is required::
80+ 如果工作簿确实有表头和索引,例如 Pandas 创建的文件,那还要做更多的一些工作::
8781
8882 from itertools import islice
8983 data = ws.values
0 commit comments