cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect results with df.query()

plynton
New Contributor II

I have tried pulling a single row from a .csv using df.query()

However, the data being returned doesn't coincide with the data I'm expecting - it is pulling a different row. Here is my code:

df = spark.read.option("header",True).csv(data_fldr + "config/CHRGConfig.csv")

df = df.toPandas()

hdrlist = list(df)

xstr = "VERSION == \"" + "STPP" + "\""

print(xstr)

planlist = df.query(xstr)

for zz in planlist:

 #

 # I'm looking for non-null values

 #

 if not pd.isnull(df.loc[0,zz]):

  print(zz)

3 REPLIES 3

Hubert-Dudek
Esteemed Contributor III

Can you include a few rows of your CSV (at least one shouldn't be pulled, and one should)?

plynton
New Contributor II

Hubert - I've found a workaround for this, so we can close the discussion.

Thank you!

Anonymous
Not applicable

Hi @Peter Ott​ 

Does @Hubert Dudek​  response answer your question? If yes, would you be happy to mark it as best so that other members can find the solution more quickly?

We'd love to hear from you.

Thanks!

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!