简体   繁体   English

Pandas Dataframe 中的相同索引,删除 NaN 行

[英]Same index in Pandas Dataframe, delete NaN rows

How can I get the data from this dataframe into 2 rows only, deleting the NaN?我怎样才能从这个 dataframe 获取数据到 2 行,删除 NaN? (I concated 3 different Dataframes into a new one, showing averages from another Dataframe) enter image description here (我将 3 个不同的数据帧合并为一个新数据帧,显示另一个数据帧的平均值)在此处输入图像描述

This is what i want to achieve:这就是我想要实现的目标:

0 Bitcoin (BTC) 36568.673315   5711.3.059220.      1.229602e+06
1 Ethereum (ETH) 2550.870272   670225.756425       8.806719e+05

It can either be in a new dataframe or using the old one.它可以在新的 dataframe 中,也可以使用旧的。 Thank you so much for ur help:)非常感谢您的帮助:)

Try this:尝试这个:

df.bfill(axis ='rows', inplace=True) # filling the missing values
df.dropna(inplace=True) # drop rows with Nulls

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM