how to index the column after data.columns



  • The table on the Campaing_id column needs to be indexed, but after the line in the ID Company, it is not possible to index.

    введите сюда описание изображения

    data(index_col='ID компании')
    

    It's a mistake.



  • The simplest thing in your case is to indicate the number of the column that should be an index when reading the file:

    data = pd.read_csv(filename, index_col=0)
    

    If it's important for you to have a name, you can do that:

    data = pd.read_csv(filename, index_col=0).rename_axis("ID компании")
    

    After that, you can rename the columns, but just take it that ID компании You don't have to tell me now that it's an index, not one of the pillars.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2