Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pandas
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f8/7f/5b047effafbdd34e52c9e2d7e44f729a0655efafb22198c45cf692cdc157/pandas-2.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB)
[2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m12.4/12.4 MB[0m [31m6.0 MB/s[0m eta [36m0:00:00[0m00:01[0m00:01[0m
[?25hRequirement already satisfied: python-dateutil>=2.8.2 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from pandas) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from pandas) (2024.1)
Collecting tzdata>=2022.1 (from pandas)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a6/ab/7e5f53c3b9d14972843a647d8d7a853969a58aecc7559cb3267302c94774/tzdata-2024.2-py2.py3-none-any.whl (346 kB)
Requirement already satisfied: numpy>=1.20.3 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from pandas) (1.24.4)
Requirement already satisfied: six>=1.5 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
Installing collected packages: tzdata, pandas
Successfully installed pandas-2.0.3 tzdata-2024.2
[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.[0m[33m
[0m
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: matplotlib in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (3.7.5)
Requirement already satisfied: contourpy>=1.0.1 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (1.1.1)
Requirement already satisfied: cycler>=0.10 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (4.54.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (1.4.7)
Requirement already satisfied: numpy<2,>=1.20 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (1.24.4)
Requirement already satisfied: packaging>=20.0 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (24.1)
Requirement already satisfied: pillow>=6.2.0 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (10.4.0)
Requirement already satisfied: pyparsing>=2.3.1 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (3.1.4)
Requirement already satisfied: python-dateutil>=2.7 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (2.9.0.post0)
Requirement already satisfied: importlib-resources>=3.2.0 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from matplotlib) (6.4.0)
Requirement already satisfied: zipp>=3.1.0 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from importlib-resources>=3.2.0->matplotlib) (3.20.2)
Requirement already satisfied: six>=1.5 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.[0m[33m
[0m
<matplotlib.legend.Legend at 0x7fcc745b7850>
<Figure size 640x480 with 0 Axes>
11. 数据输入/输出
1. csv
# 输出csv
df.to_csv('foo.csv')
# 输入csv
mid = pd.read_csv('foo.csv')
mid[:5]
Unnamed: 0
A
B
C
D
0
2000-01-01
1.935169
-0.357413
-0.610720
-0.888047
1
2000-01-02
1.716798
0.895592
-0.827020
-1.707031
2
2000-01-03
0.769426
1.589204
-0.992573
-3.305788
3
2000-01-04
1.602683
2.225518
-1.860329
-2.416657
4
2000-01-05
0.337869
4.107487
-2.186224
-3.856869
2. HDF5
!pip install tables
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting tables
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/05/49/e392c92132b950c3a8bdbb66c687a82e808edd89024e73358084bf96e044/tables-3.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.5 MB)
[2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m6.5/6.5 MB[0m [31m1.3 MB/s[0m eta [36m0:00:00[0ma [36m0:00:01[0mm
[?25hCollecting cython>=0.29.21 (from tables)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b2/52/eda119f98071ccde04a9a1c9c9a18fd6def025651c9d0cd01ad51d0dba36/Cython-3.0.11-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB)
[2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m3.6/3.6 MB[0m [31m2.0 MB/s[0m eta [36m0:00:00[0ma [36m0:00:01[0m
[?25hRequirement already satisfied: numpy>=1.19.0 in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from tables) (1.24.4)
Collecting numexpr>=2.6.2 (from tables)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0d/47/a2ede0e136a8ddc288b447c260aa035f3e75251f808aa61f6454b16dfd04/numexpr-2.8.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (384 kB)
Collecting blosc2~=2.0.0 (from tables)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a6/dd/7e214303c2acb0807fd1ad86d78112456c0fc9397f565ab86ebd147f2a9b/blosc2-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB)
[2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m3.9/3.9 MB[0m [31m1.9 MB/s[0m eta [36m0:00:00[0ma [36m0:00:01[0mm
[?25hRequirement already satisfied: packaging in /root/anaconda3/envs/pyspark/lib/python3.8/site-packages (from tables) (24.1)
Collecting py-cpuinfo (from tables)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e0/a9/023730ba63db1e494a271cb018dcd361bd2c917ba7004c3e49d5daf795a2/py_cpuinfo-9.0.0-py3-none-any.whl (22 kB)
Collecting msgpack (from blosc2~=2.0.0->tables)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/55/f6/d4859a158a915be52eecd52dee9761ab3a5d84c834a1d13ffc198e068a48/msgpack-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (381 kB)
Installing collected packages: py-cpuinfo, numexpr, msgpack, cython, blosc2, tables
Successfully installed blosc2-2.0.0 cython-3.0.11 msgpack-1.1.0 numexpr-2.8.6 py-cpuinfo-9.0.0 tables-3.8.0
[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.[0m[33m
[0m
# 输出h5文件
df.to_hdf('foo.h5','df')
# 输入csv
mid = pd.read_hdf('foo.h5','df')
mid[:5]
A
B
C
D
2000-01-01
1.935169
-0.357413
-0.610720
-0.888047
2000-01-02
1.716798
0.895592
-0.827020
-1.707031
2000-01-03
0.769426
1.589204
-0.992573
-3.305788
2000-01-04
1.602683
2.225518
-1.860329
-2.416657
2000-01-05
0.337869
4.107487
-2.186224
-3.856869
3. Excel
!pip install openpyxl
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting openpyxl
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c0/da/977ded879c29cbd04de313843e76868e6e13408a94ed6b987245dc7c8506/openpyxl-3.1.5-py2.py3-none-any.whl (250 kB)
Collecting et-xmlfile (from openpyxl)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c1/8b/5fe2cc11fee489817272089c4203e679c63b570a5aaeb18d852ae3cbba6a/et_xmlfile-2.0.0-py3-none-any.whl (18 kB)
Installing collected packages: et-xmlfile, openpyxl
Successfully installed et-xmlfile-2.0.0 openpyxl-3.1.5
[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.[0m[33m
[0m