[DataFrame] Implemented __getattr__ (#1753)

* __getattr__ accesses columns

* Added test
This commit is contained in:
Peter Schafhalter
2018-04-10 10:19:33 -07:00
committed by Devin Petersohn
parent e82bea40b1
commit 405b05d58a
2 changed files with 33 additions and 0 deletions
@@ -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()