List how many times a field is used in a column

This commit is contained in:
Jeff Moe 2024-09-19 19:15:40 -06:00
parent f2e145092a
commit 5b02a6198f

View file

@ -77,9 +77,11 @@ def csv_non_empty(CSV):
non_empty_columns = {
col: df[col].count() for col in df.columns if not df[col].isnull().all()
}
if non_empty_columns:
print("Number of non-empty values for each column:")
for col, count in non_empty_columns.items():
sorted_columns = sorted(non_empty_columns.items(), key=lambda x: x[1], reverse=True)
if sorted_columns:
for col, count in sorted_columns:
print(f"{col}: {count}")
else:
print("No non-empty values found.")