简体   繁体   English

熊猫面板.dropna行为

[英]Pandas Panel .dropna behavior

I have an array here that describes some data in a pandas Panel . 这里有一个数组,描述了pandas Panel中的一些数据。 I would like to drop the NaN s (which are rows along the major axis) and leave the data intact but it seems that calling .dropna(axis=1, how='any') will discard one row from the item that has 10 good rows and calling .dropna(axis=1, how='all') will leave one row of NaN s on the item that has 9 good rows. 我想删除NaN (沿主轴的行)并保留数据不变,但似乎调用.dropna(axis=1, how='any')将丢弃具有10个项目的一行好行并调用.dropna(axis=1, how='all')将在具有9个好行的项上保留NaN的一行。 How can I dispose of the NaN s without loosing data? 如何处理NaN而不丢失数据?

You still need to have the same dimensions in the two items of your panel. 面板的两个项目中仍需要具有相同的尺寸。 So because in the second item you have 4 NaN rows and in the first 3, you will always have to either keep one NaN row in the second item or throw away one non-NaN row in the first item. 因此,因为在第二个项目中有4个NaN行,而在前三个中,您将总是必须在第二个项目中保留一个NaN行或在第一个项目中丢弃一个非NaN行。 If you don't want that, then you have to work in two seperate dataframes so they can end up with a different number of rows. 如果您不希望这样做,则必须在两个单独的数据帧中工作,这样它们才能以不同数量的行结束。

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

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