python - Python数据框第一列偏移量
问题描述
我正在使用 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 中。
解决方案
推荐阅读
- ios - iOS Beta 5 SwiftUI 列表重复单个项目
- c++ - C++ Primer 第 5 版练习 3.20 向向量添加元素
- c# - Group by 语句无法翻译成 SQL
- php - 确保没有缺失的列值被发送到 INSERT 语句
- python - 如何从张量元组创建 TF 数据集?(和最佳实践)
- splunk - 在 Splunk 中,如何为柱形图中的条形设置固定颜色?
- javascript - 如何从 JSON 对象中获取匹配的键值?
- java - 如何限制flexbox中显示的项目数量?
- mongodb - mongoDB bindIp 允许通过 VPC 从 lambda 连接
- javascript - 在 onclick 函数中重置 JavaScript 添加的样式