pydata/pandas — pull request #5036 by unutbu (2013-09-29 03:47:22+00:00)
Title: R dataset

Motivation for this pull request came from this problem: http://stackoverflow.com/q/19039356/190597.

The problems:

- `pandas.rpy.common.load_data` currently fails to load high-dimensional arrays such as the "Titanic" dataset. `load_data` prints an error to stdout and returns None.

- Applying `load_data` to "iris3", "state.division" or "state.region" R datasets currently raise a TypeError.

- Timeseries R data is currently converted to lists that lack a time series index.

- Factor data is converted to a list of index numbers without any levels information.

This pull request:

- Provides code which converts allows `load_data` to convert the "Titanic" dataset (and similar high-dimensional arrays) to "melted" DataFrames. The code *does not* use R's melt function, since that would introduce a new dependency.

- load_data now returns a DataFrame for arrays like "iris3".

- load_data converts R factors like "state.division" and "state.region" to lists which use the levels as values.

- load_data converts ts (timeseries) R data, like "airmiles" to Series with an index showing the times. Note however I wasn't able to convert the index to a DatetimeIndex since the same code is used to convert numeric R data (like "euro") which does not have a time-related index.

- Provides unit tests which highlight the problems mentioned above, and tests for what I think is more desireable behavior as described above.