OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to print out location in Polars?

  • Thread starter Thread starter Leafy
  • Start date Start date
L

Leafy

Guest
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?

Code:
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.")
<p>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.</p>
<p>I've managed to printout the columns but not the rows.
How do I go about doing this?</p>
<pre><code>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.")
</code></pre>
 

Online statistics

Members online
0
Guests online
3
Total visitors
3
Top