Skip to content
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

Add DataTable.ltypes property #131

Merged
merged 2 commits into from Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/changelog.rst
Expand Up @@ -11,6 +11,7 @@ Changelog


**v0.1.0** September <TBD>, 2020
* Add DataTable.ltypes property to return series of logical types (:pr:`131`)
* Add ability to create new datatable from specified columns with ``dt[[columns]]`` (:pr:`127`)
* Handle setting and tagging of index and time index columns (:pr:`125`)
* Add combined tag and ltype selection (:pr:`124`)
Expand Down
4 changes: 4 additions & 0 deletions woodwork/data_table.py
Expand Up @@ -98,6 +98,10 @@ def types(self):
df.index.name = 'Data Column'
return df

@property
def ltypes(self):
return self.types['Logical Type']

def _create_columns(self,
column_names,
logical_types,
Expand Down
21 changes: 21 additions & 0 deletions woodwork/tests/data_table/test_datatable.py
Expand Up @@ -251,6 +251,27 @@ def test_datatable_types(sample_df):
assert isinstance(tag, set)


def test_datatable_ltypes(sample_df):
dt = DataTable(sample_df)
returned_types = dt.ltypes
assert isinstance(returned_types, pd.Series)
assert returned_types.name == 'Logical Type'
assert len(returned_types.index) == len(sample_df.columns)
assert all([issubclass(logical_type, LogicalType) for logical_type in returned_types.values])
correct_logical_types = {
'id': WholeNumber,
'full_name': NaturalLanguage,
'email': NaturalLanguage,
'phone_number': NaturalLanguage,
'age': WholeNumber,
'signup_date': Datetime,
'is_registered': Boolean
}
correct_logical_types = pd.Series(list(correct_logical_types.values()),
index=list(correct_logical_types.keys()))
assert correct_logical_types.equals(returned_types)


def test_datatable_physical_types(sample_df):
dt = DataTable(sample_df)
assert isinstance(dt.physical_types, dict)
Expand Down