I’m making a program which detects any negative values included within an excel spreadsheet.
I’ve converted my dataframe to Polars for faster operation.
I’ve managed to printout the columns but not the rows.
How do I go about doing this?
book = r"filename.xlsx"
pd_df = pd.read_excel(book, sheet_name='sheet_name')
df = pl.from_pandas(pd_df)
negative_values = False
for col in df.columns:
if df[col].dtype == pl.datatypes.Float64 or df[col].dtype == pl.datatypes.Int64:
filtered_df = df.filter(pl.col(col)<0)
if filtered_df.height > 0:
negative_values = True
print(col)
if not negative_values:
print("No negative values found in the DataFrame.")