-2

Trying to drop a unnamed column from a dataframe created from a Xlsx but it won't drop.

def create_final_table(self):
    self.raw_data_tables["sales_codes"] = self.raw_data_tables["sales_codes"].drop(columns=['Unnamed: 0'])
    self.raw_data_tables["vehicle_hash"] = self.raw_data_tables["vehicle_hash"].drop(
        columns=['Unnamed: 0', 'record_source', 'load_ts'])

When I execute this code it doesnt drop the Unnamed column. If I delete the ".drop(columns=['Unnamed: 0'])" command I get the same result as with this command.

SumSum
  • 47
  • 10

1 Answers1

0

You can try this:

 def create_final_table(self):
        self.raw_data_tables["sales_codes"] = self.raw_data_tables["sales_codes"].drop('Unnamed: 0', axis='columns')
        self.raw_data_tables["vehicle_hash"] = self.raw_data_tables["vehicle_hash"].drop(['Unnamed: 0', 'record_source', 'load_ts'], axis='columns')
Shri Tech1404
  • 72
  • 1
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 01 '22 at 15:51