Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  Data Science Forum on Focal Point     NameError(name 'pd' is not defined)
Go
New
Search
Notify
Tools
Reply
  
NameError(name 'pd' is not defined)
 Login/Join
 
Member
posted
I'm trying to add a synonym to my Python 3.6 adapter. When adding the synonym I'm able to input my custom script, the function is found, and I enter my sample CSV, but when I try to run/create the synonym I've been running into this error: "NameError(name 'pd' is not defined)".

My script uses pandas to generate a DataFrame from a SQL source and I've verified that my script runs independently with the appropriate import statement (import pandas as pd). I've also verified that the Python 3.6 adapter passes the test to verify that all necessary python packages are installed on the server (including pandas). I've even verified using "pip list" that the package for pandas is present.

Has anyone else encountered this issue? I've submitted a support ticket and have been in contact with an IBI support agent, but we haven't found a resolution yet. Any tips or suggestions would be appreciated.
 
Posts: 2 | Registered: July 16, 2019Reply With QuoteReport This Post
Member
posted Hide Post
Hi Joe,

As Information Builders product manager for data science I am working with Tech Support and we will get your Python script working. To make sure you, Tech Support, and I all stay in the loop I am sending my observations from reviewing your code and all changes directly to the Tech Support agent you are working with.

Here are a few general tips for anyone working with the Python and the Python adapter:

1. When a Python program is read by the Python interpreter it parses all user written functions, e.g.,
 def my_function(fruit='apple', color='red'):
, but does not run them. Syntax errors will be flagged, but not run time errors.

2. To run your Python script outside of WebFOCUS and have the "entry point" or user written function executed requires using a common Python programming technique at the end of the script:
if __name__ == '__main__':
    my_function(csvin='name of test input csv file', csvout='name of csv output file')


my_function should be replaced by the name of the actual user written function. This code block is only executed when the script is directly executed but not when imported. It will not be executed by the Python adapter because it imports the script.

3. I recommend a Python editor that will help catch coding syntax errors, such as JetBrains' community version of PyCharm.

4. Always ensure a Python script runs correctly (using item # 2 above), executing it from the operating system command line or from a Python IDE like PyCharm, before using it with the Python adapter. This is what I do when writing Python scripts and when I wrote the Summit 2019 Python adapter lab. It saved me a lot of time.

Regards,
Ira

This message has been edited. Last edited by: Ira Kaplan,


WebFOCUS 8.x, Windows 10, Ubuntu Linux
 
Posts: 17 | Location: New York City | Registered: March 01, 2010Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  Data Science Forum on Focal Point     NameError(name 'pd' is not defined)

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.