I write a short program like this:
coding: utf-8
from pandas import DataFrame from string import letters
df = DataFrame( {'a': range(0, 10), 'b': range(10, 20), 'c': range(20, 30)}, index=list(letters[:10]) ) rec = df.ix['A'] rec['a'] = 1 print df
When I run it with ipython, everything is fine!
$ ipython test.py
a b c A 1 10 20 B 1 11 21 C 2 12 22 D 3 13 23 E 4 14 24 F 5 15 25 G 6 16 26 H 7 17 27 I 8 18 28 J 9 19 29
But when I run it just use python,I get this below:
$ python test.py
Traceback (most recent call last):
File "test.py", line 9, in
Why pandas act different when I use just python?
python version = 2.7.6 ipython version = 4.0.0 pandas version = 0.16.2
Comment From: jorisvandenbossche
You will have to try to debug this yourself, but a good start is by putting the print df
before the offending line (it is df.ix['A']
that is failing). Further, certainly check it is running the same python (eg put print pandas.__path__
in the script)
I guess this has to do with the string.letters
, this returns capital or lowercase letters depending on the locale setting. At least for me, it returns lower case characters, with the result that your example script fails for me as well.
Comment From: xmduhan
@jorisvandenbossche Thank you! It cause by string.letters.