Tag Archives: python

Pandas notes

  1. Set index to column: df.set_index(‘A’)
  2. Column values to list: df[‘A’].tolist()
  3. Add new columns: df[‘new’] = input_list()
  4. Change header: df.columns=[‘new_A’, ‘new_B’]
  5. Set label with pandas plot: ax = df.flot(), ax.set_xlabel(“Xlabel”), ax.set_ylabel(“YLabel”)

How to install https://github.com/flaviovdf/pyksc

1. Problem with Cython: whenever run: cython, it returns an error of wrong version between python and cython (python in anaconda is 4, while cython default is linked to other python version which is 2).
SOLUTION: specify PYTHONPATH to /anaconda/lib/python2.7/site-packages ==> it will search in this directory, otherwise it will search on the default python

2. Problem with pyksc/dist.c:246:19: error: cblas.h: No such file or directory
SOLUTION: install openBlas, with the notes that:
“For the compatibility with old compilers (GCC < 4.4), you can enable NO_AVX flag. For example, make NO_AVX=1” (https://github.com/xianyi/OpenBLAS/wiki/Installation-Guide)

3. Add -I/home/ntran/.local/openblas/include/ to extra_compile_args in setup.py, to solve the error: pyksc/dist.c:246:19: error: cblas.h: No such file or directory
or tell gcc read the options using:
export LIBRARY_PATH=/home/ntran/.local/openblas/lib/
export C_INCLUDE_PATH=/home/ntran/.local/openblas/include/
export CPLUS_INCLUDE_PATH=/home/ntran/.local/openblas/include/
export LD_LIBRARY_PATH=/home/ntran/.local/openblas/lib/

4. Problem with from pyksc import dist (undefined symbol:cblas_ddot)
Solution: tell the pyksc using openblas instead.
4.1 See the links: ldd /home/ntran/anaconda/lib/python2.7/site-packages/pyksc/dist.so
4.2 Set in the setup.py the libraries=[‘blas’, ‘openblas‘]
4.3 –> problem of libopenblas.so.0 ==> null value
4.4 gcc -pthread -shared -I/home/ntran/.local/openblas/include -L/home/ntran/.local/openblas/lib/ -Wl,-rpath=/home/ntran/.local/openblas/lib/,--no-as-needed build/temp.linux-x86_64-2.7/pyksc/dist.o -L/home/ntran/.local/openblas/lib/ -lblas -lopenblas -o build/lib.linux-x86_64-2.7/pyksc/dist.so -fopenmp (Ref: https://www.acrc.bris.ac.uk/pdf/linking-with-libraries.pdf)
(-rpath=/home/ntran/.local/openblas/lib/; -L/home/ntran/.local/openblas/lib/, -I/home/ntran/.local/openblas/include)

5. 02.03.2016 Problem with cannot find -lblas. SOLUTION: remove [‘blas’] in the setup.py, put [‘openblas’] instead