0

I'm using a python to call an API and load it to a data frame, pretty simple code:

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)

The problem is the output has the first column header offset and when I load this data into powerBI it ignores the first column:

                     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

How should I get that first column in the same alignment as the other columns which should make it import into powerBI properly.

tc_NYC
  • 192
  • 1
  • 2
  • 11
  • 1
    The first thing you think is a column is really the `Index` with the name `'IndustryId'`. Just do `df = df.reset_index()`. https://stackoverflow.com/questions/55027108/pandas-rename-index/55028542#55028542 is an example that shows you the placement of index and column names (the last example with just a named index is what you have here). – ALollz Mar 19 '20 at 16:51
  • Got it, thank you! Works perfectly. – tc_NYC Mar 19 '20 at 16:57

0 Answers0