Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python3 and pandas

I have checked some other SO answers and googled somewhat extensively and cannot seem to find someone who has asked/answered this:

I am running Ubuntu 12.04. I have python2.7 and python3.2 installed. (I ran sudo apt-get install python-numpy, python3-numpy, and similar with scipy). I ran sudo apt-get install python-pandas. It works perfectly fine with python2.7. It does not import in python3.2 I then modified my $PYTHONPATH to have the directory where pandas was installed, full aware that this might create an issue:

/usr/lib/pymodules/python2.7

Now when I try to import, I get

>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/pandas/__init__.py", line 10, in <module>
import pandas.lib as lib
ImportError: /usr/lib/pymodules/python2.7/pandas/lib.so: undefined symbol: _Py_ZeroStruct

So I've obviously missed something here. As a note, since I've just been doing all these python installations myself, and am still learning, my $PYTHONPATH may need updating; right now the only thing in it is the directory mentioned above. Are there other directories I should have in there, standardly?

(If you need any more information about my system, etc., please just comment.)

like image 477
dwanderson Avatar asked Sep 20 '13 22:09

dwanderson


People also ask

Is Python and pandas the same?

Pandas is an open source Python package that is most widely used for data science/data analysis and machine learning tasks. It is built on top of another package named Numpy, which provides support for multi-dimensional arrays.

Why pandas are used in Python?

Pandas is built on top of two core Python libraries—matplotlib for data visualization and NumPy for mathematical operations. Pandas acts as a wrapper over these libraries, allowing you to access many of matplotlib's and NumPy's methods with less code.

Do I need Python for pandas?

Cython (writing C extensions for pandas) For many use cases writing pandas in pure Python and NumPy is sufficient. In some computationally heavy applications however, it can be possible to achieve sizable speed-ups by offloading work to cython.

Why is it called Panda in Python?

What is Pandas? Pandas is a Python library used for working with data sets. It has functions for analyzing, cleaning, exploring, and manipulating data. The name "Pandas" has a reference to both "Panel Data", and "Python Data Analysis" and was created by Wes McKinney in 2008.


3 Answers

You may just install it by sudo apt-get install python3-pandas if you'd prefer a system-wide installation

like image 84
dmeu Avatar answered Oct 21 '22 20:10

dmeu


Update

As mentioned below, pandas is now available for python 3.3, 3.4 and 3.5 source

For system wide install use:

sudo apt-get install python3-pandas

Original:

If this information http://packages.ubuntu.com/precise/python/ is correct there is no pandas package for Python 3. You can install current pandas using virtualenv:

apt-get install python-virtualenv virtualenvwrapper

mkvirtualenv -p python3 pandas_env
pip install pandas

Generally it is a good idea to create separate virtual environments when working with Python and to avoid manual messing with system wide packages.

like image 36
4 revs, 2 users 59% Avatar answered Oct 21 '22 19:10

4 revs, 2 users 59%


there is a python3-pip which will install pip-3.3 instead of pip. the pip-3.3 will install the pandas package into python3.3

like image 3
timeislove Avatar answered Oct 21 '22 21:10

timeislove