cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
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!

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.