Skip to content

Commit

Permalink
Drop based on pre-computed isnull() instead of dropna()
Browse files Browse the repository at this point in the history
Both Series.isnull() and DataFrame.dropna() accomplish the same thing,
but use just one to improve readability.
  • Loading branch information
victorlin committed Oct 25, 2022
1 parent 0826806 commit 61aeda6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions augur/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ def get_groups_for_subsampling(strains, metadata, group_by=None):
if 'year' in generated_columns_requested:
# Skip ambiguous years.
df_skip = metadata[metadata[f'{temp_prefix}year'].isnull()]
metadata.dropna(subset=[f'{temp_prefix}year'], inplace=True)
metadata.drop(df_skip.index, inplace=True)
for strain in df_skip.index:
skipped_strains.append({
"strain": strain,
Expand All @@ -1066,7 +1066,7 @@ def get_groups_for_subsampling(strains, metadata, group_by=None):
if 'month' in generated_columns_requested:
# Skip ambiguous months.
df_skip = metadata[metadata[f'{temp_prefix}month'].isnull()]
metadata.dropna(subset=[f'{temp_prefix}month'], inplace=True)
metadata.drop(df_skip.index, inplace=True)
for strain in df_skip.index:
skipped_strains.append({
"strain": strain,
Expand All @@ -1083,7 +1083,7 @@ def get_groups_for_subsampling(strains, metadata, group_by=None):
if 'week' in generated_columns_requested:
# Skip ambiguous days.
df_skip = metadata[metadata[f'{temp_prefix}day'].isnull()]
metadata.dropna(subset=[f'{temp_prefix}day'], inplace=True)
metadata.drop(df_skip.index, inplace=True)
for strain in df_skip.index:
skipped_strains.append({
"strain": strain,
Expand Down

0 comments on commit 61aeda6

Please sign in to comment.