python - 如何从数据框中排除特定行?
问题描述
我正在关注“统计学习简介”,但在 python 而不是 R 中做所有事情。我试图获取我的数据框并从中排除某些行,然后汇总这些行以获得新值。我的代码似乎没有这样做,我想知道问题可能出在哪里?
当我第二次使用 .describe 函数时,我得到的值完全相同,没有任何变化。我想知道问题是什么。
这是代码:
autoData = pd.read_csv('Auto.csv')
print(autoData.describe()) # Gives all the information. The range, std, mean etc
auto2 = autoData.drop(autoData.iloc[:10, 85:])
print(auto2.describe())```
解决方案
不要删除这些行,而是对要保留的行进行切片:
auto2 = autoData.iloc[10:,:85]
推荐阅读
- r - 有没有办法从列中的最后一个非空白值中提取?
- java - 无法在继承类的构造函数中重新分配最终变量
- python - pybind11中如何处理指针类型参数?
- sql - 将varchar转换为时间戳,然后按ticketid添加时间组
- symfony4 - JMS Serializer 不会在 Symfony 4 中加载元数据配置
- javascript - Apollo graphql 的文档指出“客户端”是结果的属性
- c# - 解析值时遇到意外字符: 。路径'',第 1 行,位置 1
- sql-server - 为来自两个不同表的两个条件输入 1 个参数
- python - 如何使用 Snack TUI 在标签小部件中显示当前值 CheckTree
- c# - UWP x:bind 双向绑定