Skip to content

Conversation

@wesm
Copy link
Member

@wesm wesm commented Jul 29, 2017

No description provided.

…m_pandas

Change-Id: I7fdd4c32b2f54d3003c6b87b9ae13186c35bcec0


def construct_metadata(df, index_levels, preserve_index, types):
def construct_metadata(df, column_names, index_levels, preserve_index, types):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pass the column_names instead of:

column_names = [str(col) for col in df.columns]

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these got sanitized earlier as part of creating the schema

return 0


cdef tuple _dataframe_to_arrays(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity , why was this written in cython originally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started small, got bigger =)

@icexelloss
Copy link
Contributor

I didn't compare "dataframe_to_arrays" with the original cython implementation too carefully. I assume they are the same except for the column name casting?

Otherwise LGTM


for name in df.columns:
col = df[name]
if not isinstance(name, six.string_types):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows anything that isn't a string including floats, timestamps, and other any wacky thing someone puts in a column index. Should this be more strict about what type(df.columns) is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a lot of cases it will just be "Index". I'd rather have someone complaining about this rather than pre-emptively guessing what will be the right thing to do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

df['a'] = df['a'].astype('category')
self._check_pandas_roundtrip(df)

def test_non_string_columns(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a test for additional column types that either fails or explicitly succeeds based on what we decide about allowing other types in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we can leave this as the only test right now and say that anything other integers or strings is undefined behavior.

),
'pandas_version': pd.__version__,
}
).encode('utf8')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll start making more local variables :)

Copy link
Contributor

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@asfgit asfgit closed this in 4108bda Jul 29, 2017
@wesm wesm deleted the ARROW-1291 branch July 29, 2017 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants