-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[DataFrame] Implemented __setitem__, select_dtypes, and astype #1941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
057f4b1
b6da366
42daa2d
4a9fa6b
c2a452d
081d9dd
f407529
993582b
8ad6e5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -905,10 +905,28 @@ def test_assign(): | |
|
|
||
|
|
||
| def test_astype(): | ||
| ray_df = create_test_dataframe() | ||
| td = TestData() | ||
| ray_df_frame = from_pandas(td.frame, 2) | ||
| our_df_casted = ray_df_frame.astype(np.int32) | ||
| expected_df_casted = pd.DataFrame(td.frame.values.astype(np.int32), | ||
| index=td.frame.index, | ||
| columns=td.frame.columns) | ||
|
|
||
| with pytest.raises(NotImplementedError): | ||
| ray_df.astype(None) | ||
| assert(ray_df_equals_pandas(our_df_casted, expected_df_casted)) | ||
|
|
||
| our_df_casted = ray_df_frame.astype(np.float64) | ||
| expected_df_casted = pd.DataFrame(td.frame.values.astype(np.float64), | ||
| index=td.frame.index, | ||
| columns=td.frame.columns) | ||
|
|
||
| assert(ray_df_equals_pandas(our_df_casted, expected_df_casted)) | ||
|
|
||
| our_df_casted = ray_df_frame.astype(str) | ||
| expected_df_casted = pd.DataFrame(td.frame.values.astype(str), | ||
| index=td.frame.index, | ||
| columns=td.frame.columns) | ||
|
|
||
| assert(ray_df_equals_pandas(our_df_casted, expected_df_casted)) | ||
|
|
||
|
|
||
| def test_at_time(): | ||
|
|
@@ -2150,7 +2168,7 @@ def test_reindex(): | |
| ray_df = create_test_dataframe() | ||
|
|
||
| with pytest.raises(NotImplementedError): | ||
| ray_df.reindex() | ||
| ray_df.reindex(None) | ||
|
||
|
|
||
|
|
||
| def test_reindex_axis(): | ||
|
|
@@ -2524,10 +2542,25 @@ def test_select(): | |
|
|
||
|
|
||
| def test_select_dtypes(): | ||
| ray_df = create_test_dataframe() | ||
|
|
||
| with pytest.raises(NotImplementedError): | ||
| ray_df.select_dtypes() | ||
| df = pd.DataFrame({'test1': list('abc'), | ||
| 'test2': np.arange(3, 6).astype('u1'), | ||
| 'test3': np.arange(8.0, 11.0, dtype='float64'), | ||
| 'test4': [True, False, True], | ||
| 'test5': pd.date_range('now', periods=3).values, | ||
| 'test6': list(range(5, 8))}) | ||
| include = np.float, 'integer' | ||
| exclude = np.bool_, | ||
| rd = from_pandas(df, 2) | ||
| r = rd.select_dtypes(include=include, exclude=exclude) | ||
|
|
||
| e = df[["test2", "test3", "test6"]] | ||
| assert(ray_df_equals_pandas(r, e)) | ||
|
|
||
| try: | ||
| rdf.DataFrame().select_dtypes() | ||
| assert(False) | ||
| except ValueError: | ||
| assert(True) | ||
|
|
||
|
|
||
| def test_sem(): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code (and below) is somewhat hard to read, and can be wrapped up into the if-else cases above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code using map in particular?