This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

For Loop Causes Name Error

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,

I have a question regarding for loops. I have a for loop that I would like to iterate through directories, subdirectories, and files looking for .*gz file extensions and then unpacking them to a list which I would later like to turn into a Pandas data frame.

I'm using this loop:




After running the above-mentioned code, I get the following error message:

"NameError Traceback (most recent call last)
<ipython-input-5-40ae48c7e923> in <module>()
10 pdFrame.append(value)
11 data_frame = pd.concat(pdFrame, axis=1, ignore_index=False)
---> 12 data_frame.to_csv('final_samples.csv', header=True)
13
14

NameError: name 'data_frame' is not defined"

From what I found so far, it seems like one of my variables is not being defined because my if clause is not being evaluated as true. I have tried initializing the data_frame variable outside of the loop, however that hasn't fixed the problem. Can someone possibly help me with this?

What I have tried:

I have tried using the following loop to check if my value is not null as follows:


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic