-
Notifications
You must be signed in to change notification settings - Fork 285
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
feat: percent empty #118
Merged
Merged
feat: percent empty #118
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b60e1c1
percent empty
a472d01
random seed
acaf769
update test name
5992169
Merge branch 'main' into feat/percent-empty
axiomofjoy dacd11f
tmp
axiomofjoy bcc84af
Merge branch 'main' into feat/percent-empty
axiomofjoy 7f663a1
update graphql schema
axiomofjoy 31c2b1f
add percent empty to ui
axiomofjoy 65c0d0e
readability improvement
axiomofjoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 17 additions & 4 deletions
21
app/src/components/model/__generated__/ModelSchemaTableDimensionsQuery.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 16 additions & 2 deletions
18
app/src/components/model/__generated__/ModelSchemaTable_dimensions.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
""" | ||
Cardinality metrics | ||
""" | ||
|
||
import concurrent.futures as cf | ||
from typing import Dict, List, Optional | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from typing import Dict, List, Optional | ||
|
||
from pandas import DataFrame | ||
|
||
|
||
def percent_empty(dataframe: DataFrame, column_names: List[str]) -> Dict[str, Optional[float]]: | ||
""" | ||
Returns a map of the dataframe column names to the percent of empty entries | ||
for each row. | ||
""" | ||
num_records = dataframe.shape[0] | ||
if num_records == 0: | ||
return {col: None for col in column_names} | ||
return dict(dataframe[column_names].isnull().sum() / num_records) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
@strawberry.enum | ||
class DataQualityMetric(Enum): | ||
cardinality = "cardinality" | ||
percentEmpty = "percentEmpty" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from numpy.testing import assert_array_almost_equal | ||
from pandas import DataFrame | ||
|
||
from phoenix.metrics.percent_empty import percent_empty | ||
|
||
|
||
def test_percent_empty_returns_correct_percents_including_for_empty_and_full_columns(): | ||
dataframe = DataFrame( | ||
{ | ||
"col0": [None, None, None], | ||
"col1": [1.0, None, None], | ||
"col2": ["string-entry", None, "another-string-entry"], | ||
"col3": [0.1, 0.2, 0.3], | ||
} | ||
) | ||
expected_column_name_to_percent_empty = { | ||
"col0": 1.0, | ||
"col1": 2 / 3, | ||
"col2": 1 / 3, | ||
"col3": 0.0, | ||
} | ||
expected_column_names = ["col0", "col1", "col2", "col3"] | ||
column_name_to_percent_empty = percent_empty( | ||
dataframe=dataframe, column_names=["col0", "col1", "col2", "col3"] | ||
) | ||
assert expected_column_names == sorted(column_name_to_percent_empty.keys()) | ||
assert_array_almost_equal( | ||
[column_name_to_percent_empty[col] for col in expected_column_names], | ||
[expected_column_name_to_percent_empty[col] for col in expected_column_names], | ||
) | ||
|
||
|
||
def test_percent_empty_returns_only_input_columns(): | ||
dataframe = DataFrame( | ||
{ | ||
"col0": [1, 2, None], | ||
"col1": [1.0, None, None], | ||
} | ||
) | ||
column_name_to_percent_empty = percent_empty(dataframe=dataframe, column_names=["col0"]) | ||
assert ["col0"] == list(column_name_to_percent_empty.keys()) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
might not be worth a dataloader tbh
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.
will address in a separate pr