mirror of
https://github.com/wassname/ray.git
synced 2026-07-01 08:36:36 +08:00
[DataFrame] Implemented __getattr__ (#1753)
* __getattr__ accesses columns * Added test
This commit is contained in:
committed by
Devin Petersohn
parent
e82bea40b1
commit
405b05d58a
@@ -2763,6 +2763,23 @@ def test___getitem__(ray_df, pd_df):
|
||||
assert pd_col.equals(ray_col)
|
||||
|
||||
|
||||
def test___getattr__():
|
||||
df = create_test_dataframe()
|
||||
|
||||
col = df.__getattr__("col1")
|
||||
assert isinstance(col, pd.Series)
|
||||
|
||||
col = getattr(df, "col1")
|
||||
assert isinstance(col, pd.Series)
|
||||
|
||||
col = df.col1
|
||||
assert isinstance(col, pd.Series)
|
||||
|
||||
# Check that lookup in column doesn't override other attributes
|
||||
df2 = df.rename(index=str, columns={"col5": "columns"})
|
||||
assert isinstance(df2.columns, pd.Index)
|
||||
|
||||
|
||||
def test___setitem__():
|
||||
ray_df = create_test_dataframe()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user