ENH: Make categorical repr nicer.
State: closed

Make looking at Categorical types a little nicer. Needs some tests still, but works fine locally so far.


Labels:

Comments:
Added tests.

@jseabold this is nice......can you hook up travis? (prob just need to flip the switch), then 

`git checkin --amend -C HEAD` to recommit last commit

Should be going now. Ping me if it's not. Maybe needed a setup lag.

does not appear to have taken.....

Appears to be going now.

Well, I don't see the banner here, but I see it running on travis. I dunno.

travis usually takes a couple of minutes to actually start, that's how it rolls

i see the banner

Anyone know off the top of their head the 2.6 errors? I assume it's a unicode comparison issue...

that kind of looks like a bug 

python 2.6:

```
Categorical:
[a, b, b, a, a, c, c, c]
Levels (3): Index([a, b, c], dtype=object)

In [10]: factor.levels
Out[10]: Index([u'a', u'b', u'c'], dtype=object)
```

python 2.7

```
In [1]: factor = Categorical.from_array(['a','b','b','a','a','c','c','c'])

In [2]: factor
Out[2]:
Categorical:
[a, b, b, a, a, c, c, c]
Levels (3): Index(['a', 'b', 'c'], dtype=object)

In [3]: factor.levels
Out[3]: Index([u'a', u'b', u'c'], dtype=object)
```

or possibly a difference in numpy since categorical repr calls np.array_repr...my python 2.6 has np 1.6.1 and py 2.7 up there has 1.7.1

yep `np.array2string` is different in those two versions of `numpy`

Thanks. For the record, y'all beat my attempts to build Python 2.6, the whole numpy stack, and pandas in the background of my work.

@jseabold building the stack is not fun. i get strange issues with `matplotlib` and tkinter so i can't do any plotting...i'm also accumulating a bit of enmity for the `timedelta64` (non-)functionality of `numpy` 1.6 (it silently _doesn't_ and then sometimes does convert units). i would suggest avoiding `numpy` 1.6 like the plague if you have the option. python 2.6 is probably ok

hah....we have had fair share of issues with py2.6 lately!

here's a fun bug in python (that was actually not fixed): http://bugs.python.org/issue2325

Yes, I switched to openblas recently and my hacked together numpy/distutils is not working for scipy (numpy tests pass) for 2.6.

Fixed the tests.

gets bit unwieldy for a large number of levels (i tried 100), but my opinion here doesn't matter that much i never use `Categorical`

I left a TODO in there for this. It's admittedly not handled, but I can't imagine having categorical variables with too many categories. The degrees of freedom loss is too prohibitive in estimation. Maybe it could be useful in some machine learning contexts, but I don't know how ML people use factors in R. I suspect they don't.

totally fine by me. like i said, i never found a need for this

@jseabold this looks ready? maybe squash a bit 

@cpcloud ?

fine by me

Too late to throw out case the repr being valid python (so it can eval itself) :s ?

@jseabold this almost got lost...

can you rebase and we can merge it in....

thxs

Rebased. There was a merge conflict, which I didn't check too closely, so make sure tests pass.

Any idea what's going on here?

Looks like a circular import introduced in 85f191cb?

merged via 7c760868f093e9370304e1d62981d4c005d2482d

thanks @jseabold