Skip to content

Commit 522563c

Browse files
committed
DOC: add section on data input/output to spreadsheet comparison
1 parent 73af8d9 commit 522563c

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

doc/source/getting_started/comparison/comparison_with_spreadsheets.rst

+33-4
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,18 @@ particular row don't change.
6262
See the :ref:`indexing documentation<indexing>` for much more on how to use an ``Index``
6363
effectively.
6464

65-
Commonly used spreadsheet functionalities
66-
-----------------------------------------
65+
Data input / output
66+
-------------------
6767

68-
Importing data
69-
~~~~~~~~~~~~~~
68+
Constructing a DataFrame from values
69+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70+
71+
In a spreadsheet, `values can be typed directly into cells <https://support.microsoft.com/en-us/office/enter-data-manually-in-worksheet-cells-c798181d-d75a-41b1-92ad-6c0800f80038>`_.
72+
73+
.. include:: includes/construct_dataframe.rst
74+
75+
Reading external data
76+
~~~~~~~~~~~~~~~~~~~~~
7077

7178
Both `Excel <https://support.microsoft.com/en-us/office/import-data-from-external-data-sources-power-query-be4330b3-5356-486c-a168-b68e9e616f5a>`__
7279
and :ref:`pandas <10min_tut_02_read_write>` can import data from various sources in various
@@ -96,6 +103,28 @@ In pandas, you pass the URL or local path of the CSV file to :func:`~pandas.read
96103
tips = pd.read_csv(url)
97104
tips
98105
106+
Like `Excel's Text Import Wizard <https://support.microsoft.com/en-us/office/text-import-wizard-c5b02af6-fda1-4440-899f-f78bafe41857>`_,
107+
``read_csv`` can take a number of parameters to specify how the data should be parsed. For
108+
example, if the data was instead tab delimited, and did not have column names, the pandas command
109+
would be:
110+
111+
.. code-block:: python
112+
113+
tips = pd.read_csv("tips.csv", sep="\t", header=None)
114+
115+
# alternatively, read_table is an alias to read_csv with tab delimiter
116+
tips = pd.read_table("tips.csv", header=None)
117+
118+
Exporting data
119+
~~~~~~~~~~~~~~
120+
121+
By default, desktop spreadsheet software will save to its respective file format (``.xlsx``, ``.ods``, etc). You can, however, `save to other file formats <https://support.microsoft.com/en-us/office/save-a-workbook-in-another-file-format-6a16c862-4a36-48f9-a300-c2ca0065286e>`_.
122+
123+
:ref:`pandas can create Excel files <io.excel_writer>`, :ref:`CSV <io.store_in_csv>`, or :ref:`a number of other formats <io>`.
124+
125+
Commonly used spreadsheet functionalities
126+
-----------------------------------------
127+
99128
Fill Handle
100129
~~~~~~~~~~~
101130

0 commit comments

Comments
 (0)