First off this is my second day writing in Python. My manager switched us off SAS and moved us to Python and R which I actually am starting to like the flexibility. I have a few datasets that I work with on a regular basis that require a lot of cleaning before I can work with them and I would rather just call a class instead of copying and pasting code every time. The class below is the most basic one of them all I just read in the extract and pull out all records containing a certain DeviceType.
Python Version: 3.3.2
class ReturnDataFrame:
import pandas as pd
from pandas import DataFrame
def FileName(self,FileName):
self.name=name
EFile = pd.read_csv(FileName,delimiter = '~',names=['DateTime','DeviceType','Identifier','ServiceID','Communication Module Serial Number'], header=None)
EFile = EFile[(EFile.DeviceType == 'X023G2Z')]
def returnFile(self):
return EFile
Below is where I load in my class and instantiate it.
This is the error I am recieving when I run X.FileName('F:/Python/WinterOnly.csv')
NameError: global name 'pandas' is not defined
import ReturnDataFrame
from ReturnDataFrame import *
X = returnDataFrame()
X.FileName('F:/Python/Week05052013.csv')
WeeklyFile = DataFrame()
WeeklyFile = WeeklyFile.append(X.returnFile())