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!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group