Смещение первого столбца Python Dataframe

Я использую python для вызова API и загрузки его в фрейм данных, довольно простой код:

import simfin as sf
import pandas as pd
import numpy as np

# Set your SimFin+ API-key for downloading data.
sf.set_api_key('free')

# Set the local directory where data-files are stored.
# The directory will be created if it does not already exist.
sf.set_data_dir('~/simfin_data/')

df_industries = sf.load_industries()

print(df_industries)

Проблема в том, что вывод имеет смещение заголовка первого столбца, и когда я загружаю эти данные в powerBI, он игнорирует первый столбец:

                     Sector                    Industry
IndustryId
100001          Industrials         Industrial Products
100002          Industrials           Business Services
100003          Industrials  Engineering & Construction
100004          Industrials            Waste Management
100005          Industrials     Industrial Distribution
...                     ...                         ...
110004      Basic Materials             Metals & Mining
110005      Basic Materials          Building Materials
110006      Basic Materials                        Coal
110007      Basic Materials                       Steel
111001                Other        Diversified Holdings

Как мне получить этот первый столбец в том же выравнивании, что и другие столбцы, чтобы он правильно импортировался в powerBI.


person tc_NYC    schedule 19.03.2020    source источник
comment
Первое, что вы принимаете за столбец, — это столбец Index с именем 'IndustryId'. Просто сделайте df = df.reset_index(). stackoverflow.com/questions/55027108/pandas-rename-index/ — это пример, показывающий размещение имен индексов и столбцов (последний пример только с именованным индексом — это то, что у вас есть).   -  person ALollz    schedule 19.03.2020
comment
Понял. Спасибо! Работает отлично.   -  person tc_NYC    schedule 19.03.2020