I have a dataframe that i am trying to format certain cell values/the row where the cell value != 0. I am ONLY looking at rows 2 and 3 based off the index (the last two rows) so I only want the condition and formatting to apply to the last two rows. Ideally, i would only like to highlight a cell under the Findings column but highlighting the row also works.
i'd like to find a condition where if ID and name check findings are ever != 0, i want that row or even just the findings cell to be red to alert me that there is an issue with the data.
Is that possible to do? I am struggling to find a way to update the specific cell value or row to RED instead of a specific column?
The condition is like
if check == 'ID Check' and findings != 0:
[code to make cell value/row red]
elif check == 'Name Check' and findings != 0:
[code to make cell value/row red]
else [default color?]
the data frame is built like this:
def record_count():
with open('filename.csv', encoding='utf8') as file:
record_number = len(list(file))
print("Number of records on file:", record_number)
return record_number
def user por_count():
df = pd.read_csv(filename.csv', low_memory=False)
user_number = df['users'].nunique()
print("Number of users on file:", str(users))
return users
def id_check():
df = pd.read_csv('filename.csv', low_memory=False)
missing_id = df["id"].isna().sum()
print("Number of users missing an id:", missing_id)
return missing_id
def name_check():
df = pd.read_csv('filename.csv', low_memory=False)
missing_name = derivs["name"].isna().sum()
print("Number of users missing a name:", missing_name)
return missing_name
checks_table = {
'Check' : ['Record Check', 'ID Check', 'Name Check'],
'Summary' : ['Number of records on file','Number of records missing an ID', 'Number of users missing a name'],
'Findings' : [record_count(), id_check(), name_check()]
}
df_checks = pd.DataFrame.from_dict(checks_table)
df_checks.head()