如何使用Python删除.fits文件中包含nan的行?
我尝试删除像这样的天文表中出现 nan 的行
a[~np.isnan(a).any(axis=1)]
,但我收到以下错误代码:
TypeError: ufunc 'isnan' 不支持输入类型,并且输入无法根据以下内容安全地强制为任何支持的类型铸造规则“安全”
I tried to remove rows where nan occurs in an astropy table like so
a[~np.isnan(a).any(axis=1)]
but i get following error-code:
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜测您想要删除该行中任何列具有 NaN 的行。那会是这样的:
I'm guessing that you want to remove rows where any column in that row has a
NaN
. That would be like so:表/数组中的 NaN 是什么样的?您报告的错误表明数字和字符的混合。如果您正在阅读带有 pandas 的表格,您可以使用 pandas.dropna() ,这在过去对我来说非常有用。
What do the NaNs look like in the table/array? The error you are reporting suggests a mixture of numbers and characters. If you are reading a table with pandas you could use pandas.dropna() which worked great for me in the past.