python numpy和pandas数据处理_python中添加数据分析工具numpy和pandas
python中添加數據分析工具numpy和pandas
最近要對一系列數據做同比比較,需要用到numpy和pandas來計算,不過使用python安裝numpy和pandas因為linux環境沒有外網遇到了很多問題就記下來了。首要條件,python版本必須是2.7以上。
linux首先安裝依賴包-y??blas?blas-devel?lapack-?-y??-y??freetype?freetype-devel?libpng?libpng-?-y??python-?-y??pytz
yum?-y?install?python-dateutil
1、 pip方式安裝
如果有外網一般推薦使用pip安裝,linux下和windows下均可使用pip安裝python?-m?pip?install?--upgrade?pip
pip?install?--user?numpy?scipy?matplotlib?jupyter?pandas?sympy?nose
但很快就會發現這些源安裝超級慢,所以我推薦大家使用豆瓣的源pip?install?matplotlib?-i?http://pypi.douban.com/simple?--trusted-host?pypi.douban.compip?install?numpy?-i?http://pypi.douban.com/simple?--trusted-host?pypi.douban.compip?install?pandas?-i?http://pypi.douban.com/simple?--trusted-host?pypi.douban.compip?install?seaborn?scipy??-i?http://pypi.douban.com/simple?--trusted-host?pypi.douban.com
tar?-xzf?numpy-1.11.2.tar.gz
cd?numpy-1.11.2python?setup.py?build??#?編譯幾分鐘
python?setup.py?install
安裝pandas會提示?ImportError: Building pandas requires cython則需要安裝Cython或者升級Cython先,下載鏈接?https://pypi.python.org/pypi/Cython/。windows下pip安裝如下pip?install?Cython
linux下可使用yum安裝或者pip安裝yum?install?-y?Cython.x86_64
如果需要更新到最新版本的Cython則下載源碼后安裝cd?Cython-0.25.1python?setup.py?build
python?setup.py?install
然后是按照pandascd?pandas-0.19.0python?setup.py?build???#?比較久
python?setup.py?install
如果遇到需要安裝?python-dateutil的提示則是該庫版本過低。先下載six最新版本1.9.0(下載地址),然后更新?python-dateutil到新版本2.5.3版本(下載地址)。
最后運行如果出現?/usr/lib64/libstdc++.so.6: ELF file OS ABI invalid的錯誤則將?/usr/lib64/libstdc++.so.6軟鏈指向低版本的?libstdc++.so.6.0.8,不要指向高版本?libstdc++.so.6.0.20。
至此就安裝成功了。
總結,花了一上午安裝這個主要是因為下載源慢,依賴包多。所以建議大家都是用pypi豆瓣源,直接在simple下面搜你需要的安裝包。
總結
以上是生活随笔為你收集整理的python numpy和pandas数据处理_python中添加数据分析工具numpy和pandas的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python协程asyncio 应用_P
- 下一篇: C语言 | 内存对齐01 - 什么是内存