0

This is my code and output shows "Empty DataFrame"

import pandas as pd
from openpyxl.workbook import Workbook

df_excel = pd.read_excel("test Data.xlsx")

print (df_excel.loc[(df_excel['Dist'] == "Sagar") & (df_excel['Site Potential'] == 200)])

Is there any error in the last line of the code?

The expected output should show all the entries with Dist "Sagar" and "Site Potential" =200. Manually,I can check that there are 2 such entries in the test file.

AlexK
  • 2,855
  • 9
  • 16
  • 27
  • 1
    How do you expect someone to be able to help you if you don't share the data that allows us to reproduce the same result? Please read  [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples), and revise your question accordingly. – Rodalm Aug 22 '22 at 19:23
  • Why are using `loc` at all here? You should be able to delete `.loc`, and the "magic indexing" will do its thing. – Tim Roberts Aug 22 '22 at 19:25
  • maybe first check what you get with `print( df_excel.loc[df_excel['Site Potential'] == 200] )` and `print( df_excel.loc[df_excel['Dist'] == "Sagar"] )` . And check if there are rows with both values at the same time. OR maybe it needs string `"200"` ? – furas Aug 22 '22 at 21:41

0 Answers0