Forums

How do I use if else in python with pandas?

Hi Everyone,

I have this code that I have done so far and I want to make it for the if-else statement in python but as result, I want that the results/errors are output in a Microsoft word document.

I have this code that I want to use in the if-else statement.

Here it is

Import pandas as pd
dfs = pd.read:excel(" excel/file", sheet_name = "sheet name", engine= "openpyxl")
print(dfs.head(10))
dfs.iloc[2:11 , 1:2].dtypes

and I want something like this :

if this = dfs.iloc[2:11 , 1:2].dtypes is object then print ("value is okay")
else:
print("value is not okay")

but the print to be printed out in one Microsoft word document. The "value is okay" is not necessary to be output but the error one is necessary.

Thank you in advance. Best Regards.

this definitely sounds like a long coding problem-- so you may want to get a mentor to help you with this. eg: here