惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
量子位
博客园 - 叶小钗
博客园_首页
Know Your Adversary
Know Your Adversary
S
Schneier on Security
罗磊的独立博客
C
Cyber Attacks, Cyber Crime and Cyber Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Simon Willison's Weblog
Simon Willison's Weblog
美团技术团队
WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
Hacker News: Ask HN
Hacker News: Ask HN
Application and Cybersecurity Blog
Application and Cybersecurity Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Security Latest
Security Latest
月光博客
月光博客
Spread Privacy
Spread Privacy
C
Cybersecurity and Infrastructure Security Agency CISA
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
C
CERT Recently Published Vulnerability Notes
Last Week in AI
Last Week in AI
Attack and Defense Labs
Attack and Defense Labs
NISL@THU
NISL@THU
H
Hacker News: Front Page
N
News and Events Feed by Topic
小众软件
小众软件
T
Threatpost
V2EX - 技术
V2EX - 技术
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
Project Zero
Project Zero
L
LINUX DO - 热门话题
Apple Machine Learning Research
Apple Machine Learning Research
C
CXSECURITY Database RSS Feed - CXSecurity.com
TaoSecurity Blog
TaoSecurity Blog
P
Privacy International News Feed
Latest news
Latest news
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog

博客园 - 哈哈

cas服务器搭建后的调整 使用python直接连接http服务器获取数据 request的url地址 numpy的多项式函数与求导 tcp与ip的包结构 江苏铁路 易经-64卦 使用python实现rpc服务 图书分类-中图法,值得一看的图书 linux时区,curl的使用,nginx日志,watch 使用selenium模仿登录,执行js python与java的交互 计算斐波那契数列 Python线程 selenium的使用 pip使用 python读取postgresql 18位身份证的验证码 python读取docx文件属性-最后一次保存的时间等
pandas相关
哈哈 · 2021-03-16 · via 博客园 - 哈哈

DataFrame的常用操作

import pandas as pd

df = pd.DataFrame([[1,2,3,4],[11,22,33,44]],columns=['a','b','c','d'])
# 增加index
df.index = ['AA','BB']
# 去掉index
df.index = [0,1]
# 去掉index,此方法不修改原来的df
df.reset_index(drop=True)
# 去掉index,此方法不修改原来的df
df.reset_index(drop=True)
#
df.loc[0]
df.loc['AA']

df.head( 5 ) #查看前5行

df.tail( 3 ) #查看后3行

df.values #查看数值

df.shape #查看行数、列数

df.fillna(0) #将空值填充0

df.replace( 1, -1) #将1替换成-1

df.isnull() #查找df中出现的空值

df.notnull() #非空值

df.dropna() #删除空值

df.unique() #查看唯一值

df.reset_index() #修改、删除,原有索引

df.columns #查看df的列名

df.index #查看索引

df.sort_values() #排序

pd.merge(df1,df2) #合并

pd.concat([df1,df2]) #合并,与merge的区别,自查

pd.pivot_table( df ) #用df做数据透视表(类似于Excel的数透)

s=pd.Series(['a','b','c','d'])

s=pd.Series(['a','b','c','d'],)

s.index #查看索引

s.values #查看数值

s.isnull() #查看为空的,返回布尔型

s.notnull()

s.sort_index() #按索引排序

s.sort_values() #按数值排序

# 生成日期序列
dates = pd.date_range('20210101', periods=5)
np.random.randn(5,4)
# 通过Series生成DataFrame
df2=pd.DataFrame({'A':1,'B':np.array([3]*4),'C':['AA','BB','CC','DD']})
# DataFram增加一行
s=pd.Series([2,4,6,8],index=['a','b','c','d'])
df.append(s,ignore_index=True)
# 或者写在一起
df.append([{'a':2,'b':4,'c':6,'d':8}],ignore_index=True)
# 注意,如果不用ignore_index,增加的index会有问题
# DataFram增加一列
s=pd.Series([5,55])
df['e']=s
# 如果有index列,则创建series的时候也需要
# 绘图
from matplotlib import pyplot as plt

df.plot()
plt.show()