从pd.read_html

时间:2019-03-27 14:23:31

标签: python pandas dataframe

我找不到如何正确索引我的数据框列

我尝试了一些方法,但是找不到正确的方法

import pandas as pd

df = pd.read_html('sbi.html')
data = df[1]

Screenshot

我希望第二行作为其中存在“ Narration”的列的索引

1 个答案:

答案 0 :(得分:1)

public class UserEntity { public int Id { get; set; } [Encrypted] public string Username { get; set; } [Encrypted] public string Password { get; set; } public int Age { get; set; } } public class DatabaseContext : DbContext { // Get key and IV from a Base64String or any other ways. // You can generate a key and IV using "AesProvider.GenerateKey()" private readonly byte[] _encryptionKey = ...; private readonly byte[] _encryptionIV = ...; private readonly IEncryptionProvider _provider; public DbSet<UserEntity> Users { get; set; } public DatabaseContext(DbContextOptions options) : base(options) { this._provider = new AesProvider(this._encryptionKey, this._encryptionIV); } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.UseEncryption(this._provider); } } 参数设置为header

1

或使用data = pd.read_html('sbi.html', header=1)[0] 参数:

skiprows