title: How to insert a data frame as an object attribute
body: <p>This is most likely a pretty basic question, but I am still learning about classes/objects/constructors/etc. and I am trying to apply some of these concepts to my current workflow.</p>
  <p>I am trying to create a class that automatically saves my data frame as a CSV or xlsx file, depending on what I specify, to a given folder. However, I don't believe that I am correctly passing my data frame as an object attribute. This is my code as it stands:</p>
  <pre><code>award_date_change = merged_df.loc[merged_df['award_date_change'] == 'yes'] #this is my data frame
  class uploading_to_GC:
      
      def __init__(self, file_name, file_type, already_exists): #constructor where I want to pass my data frame, file type to be saved to, and specifying if the file already exists in my folder
          self.file_name = file_name
          self.file_type = file_type
          self.already_exists = already_exists
      def print_file_name(self):
          self.file_name.head(5)
      
      def private_workspace(self):
          commonPath = os.path.expanduser(r&quot;~\path&quot;)
          GCdocs = commonPath + '384593683' + '\\' 
          path = GCdocs + &quot;&quot; + file_name
          
          if len(self.file_name) != 0 and self.already_exists == True: #if a file already exists in Gfolder
              if self.file_type == &quot;csv&quot;: #for csv files
                      GC_old = pd.read_csv(path)
                      GC_new = GC_old.append(self.file_name, ignore_index=True)
                      GC_new.to_csv(path, index = False)
                      print(&quot;csv file is updated to private workspace in GCdocs&quot;)
              elif self.file_type == &quot;xlsx&quot;: #for xlsx files
                      GC_old = pd.read_csv(path)
                      GC_new = GC_old.append(self.file_name, ignore_index=True)
                      GC_new.to_excel(path, index = False)
                      print(&quot;excel file is updated to private workspace in GCdocs&quot;)
              else:
                  print(&quot;unrecognized file type&quot;)
                  
                  
          elif len(self.file_name) != 0 and self.already_exists == False: #if a file does FOLDER already exist in folder
              if self.file_type == &quot;csv&quot;: 
                   self.file_name.to_csv(path,index=False)
              if self.file_type == &quot;xlsx&quot;: 
                   self.file_name.to_excel(path,index=False)
              else:
                  print(&quot;unrecognized file type&quot;)
                  
          else:
              print(&quot;there is no data to upload&quot;)
          
  award_date_change = uploading_to_GC(award_date_change,&quot;csv&quot;, False)
  award_date_change.private_workspace
  </code></pre>
  <p>I am aware that I don't need to use a class to do this, but I wanted to challenge myself to start using classes more often. Any help would be appreciated</p>