今天,我们来学习一下,Pandas中的关于行列选择的十大技能,这些技能,绝对是你使用Pandas的过程中,需要用到的,因为,你肯定也想像Excel一样,任性地操作Python中的数据框。

先来导入我们的演示数据,这里直接复制执行就可以了。
# import the pandas module
importpandasaspd# Create an example dataframe about a fictional army
raw_data={'regiment': ['Nighthawks','Nighthawks','Nighthawks','Nighthawks','Dragoons','Dragoons','Dragoons','Dragoons','Scouts','Scouts','Scouts','Scouts'],'company': ['1st','1st','2nd','2nd','1st','1st','2nd','2nd','1st','1st','2nd','2nd'],'deaths': [523,52,25,616,43,234

本文介绍了Pandas中用于数据筛选的十个实用技巧,包括选择特定列、行,条件过滤,以及通过行索引和列名定位数据等。示例数据涉及虚构军队的详细信息,如死亡人数、战斗次数等。
最低0.47元/天 解锁文章

3147

被折叠的 条评论
为什么被折叠?



