title: How to Share Variable Across the in-class def in Python
body: <pre><code>class Dataframe: #Recommended to instatiate your dataframe with your csv name.
      """
      otg_merge = Dataframe("/Users/zachary/Desktop/otg_merge.csv") #instaiate as a pandas dataframe
      """
      def __init__(self, filepath, filename = None):
          pd = __import__('pandas') #import pandas when the class is instatiated 
          self.filepath = filepath
          self.filename = filename
  
      def df(self): #it makes the DataFrame
          df = pd.read_csv(self.filepath, encoding = "cp949", index_col= 0)  #index col is not included
          return df
  
      def shape(self): #it returns the Dimension of DataFrame
          shape = list(df.shape)
          return shape
  
      def head(self): #it reutrns the Head of Dataframe
          primer = pd.DataFrame.head(df)
          del primer["Unnamed: 0"]
          return primer
  
      def cust_types(self): #it returns the list of cust_type included in .csv
          cust_type = []
          for i in range(0, shape[0]):
              if df.at[i, "cust_type"] not in cust_type: #if it's new..
                  cust_type.append(df.at[i, "cust_type"]) #append it as a new list element
          return cust_type
  </code></pre>
  
  <p>I am doing some wrapping pandas functions wrapping for whom doesn't necessarily need to know the pandas.</p>
  
  <p>If you see the code, at the third def, shape returns shape as a list of such as [11000, 134] as a xdim and ydim.</p>
  
  <p>Now I'd like to use the shape again at the last def cust_types, however,, it returns the shape is not defined.</p>
  
  <p>How can I share the variable "share" across defs in the same class? </p>
  
  <ul>
  <li>intersetingly, I didn't do nth, but the df is shared from second df to thrid shape without error </li>
  </ul>