.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\python_packages\pandas\demo_in_out.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_python_packages_pandas_demo_in_out.py: Getting data in/out ====================== .. GENERATED FROM PYTHON SOURCE LINES 5-22 .. code-block:: Python import pandas as pd import numpy as np timestamps = pd.Series( np.random.randn(1000), index=pd.date_range("1/1/2000", periods=1000) ) timestamps = timestamps.cumsum() dataFrame = pd.DataFrame( np.random.randn(1000, 4), index=timestamps.index, columns=["A", "B", "C", "D"] ) dataFrame = dataFrame.cumsum() dataFrame.to_csv("foo.csv") pd.read_csv("foo.csv") .. raw:: html
Unnamed: 0 A B C D
0 2000-01-01 -0.791861 -0.558487 0.260862 -0.827079
1 2000-01-02 -0.728893 0.018522 0.491820 0.427598
2 2000-01-03 0.801129 -0.788797 0.187535 0.424554
3 2000-01-04 0.003962 -1.998664 -0.078471 1.017862
4 2000-01-05 0.529178 -1.765030 -0.781073 1.237441
... ... ... ... ... ...
995 2002-09-22 22.183364 -29.935107 -32.450743 19.144473
996 2002-09-23 21.568148 -30.342366 -32.678239 19.158621
997 2002-09-24 22.086591 -28.859693 -32.059223 18.354344
998 2002-09-25 22.520814 -29.239886 -30.950673 18.254176
999 2002-09-26 24.098983 -29.360780 -29.249539 18.458504

1000 rows × 5 columns



.. GENERATED FROM PYTHON SOURCE LINES 24-26 .. code-block:: Python dataFrame.to_excel("foo.xlsx", sheet_name="Sheet1") pd.read_excel("foo.xlsx", "Sheet1", index_col=None, na_values=["NA"]) .. raw:: html
Unnamed: 0 A B C D
0 2000-01-01 -0.791861 -0.558487 0.260862 -0.827079
1 2000-01-02 -0.728893 0.018522 0.491820 0.427598
2 2000-01-03 0.801129 -0.788797 0.187535 0.424554
3 2000-01-04 0.003962 -1.998664 -0.078471 1.017862
4 2000-01-05 0.529178 -1.765030 -0.781073 1.237441
... ... ... ... ... ...
995 2002-09-22 22.183364 -29.935107 -32.450743 19.144473
996 2002-09-23 21.568148 -30.342366 -32.678239 19.158621
997 2002-09-24 22.086591 -28.859693 -32.059223 18.354344
998 2002-09-25 22.520814 -29.239886 -30.950673 18.254176
999 2002-09-26 24.098983 -29.360780 -29.249539 18.458504

1000 rows × 5 columns



.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.071 seconds) .. _sphx_glr_download_11_demos_python_packages_pandas_demo_in_out.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_in_out.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_in_out.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: demo_in_out.zip `