【问题标题】:Add len of two DataFrames添加两个 DataFrame 的 len
【发布时间】:2018-03-14 19:08:00
【问题描述】:

我有两个 DataFrame df1df2

我想看看两者的长度加起来是多少。

但我似乎做不到len(df1) + len(df2)

有没有快速的方法来做到这一点(不加入他们)?

【问题讨论】:

  • 为什么不能?如果我这样做,效果很好。
  • 嗯 - 我的索引可能有问题 - 让我试试

标签: python pandas dataframe count addition


【解决方案1】:

我认为最快的是 sum lengths of indexes:

len(df1.index) + len(df2.index)

但是和你的解决方案一样:

len(df1) + len(df2)

【讨论】:

  • 索引号对我有用 - 我不知道为什么没有索引的那个没有'比 kyou
【解决方案2】:

通过使用shape

df1.shape[0]+df2.shape[0]

【讨论】:

    猜你喜欢
    • 2015-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多