温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

python中的pandas怎么安装使用

发布时间:2022-05-11 14:46:12 来源:亿速云 阅读:154 作者:zzz 栏目:编程语言

这篇文章主要介绍了python中的pandas怎么安装使用的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇python中的pandas怎么安装使用文章都会有所收获,下面我们一起来看看吧。

说明

1、python+data+analysis的组合缩写,是python中以numpy和matplotlib为基础的第三方数据分析库

2、共同构成python数据分析的基本工具包,享有三个剑客的名字。

安装

打开cmd,依次输入以下三个命令。

pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple

pandas选择数据

import pandas as pd
import numpy as np
dates = pd.date_range('20210301', periods=6)
df1 = pd.DataFrame(np.arange(24).reshape((6, 4)), index=dates, columns=['A', 'B', 'C', 'D'])
print(df1)

pandas赋值及操作

import pandas as pd
import numpy as np
dates = pd.date_range('20210301', periods=6)
df1 = pd.DataFrame(np.arange(24).reshape((6, 4)), index=dates, columns=['A', 'B', 'C', 'D'])
print(df1)

pandas对于空数据的处理

import pandas as pd
import numpy as np
dates = pd.date_range('20210301', periods=6)
df1 = pd.DataFrame(np.arange(24).reshape((6, 4)), index=dates, columns=['A', 'B', 'C', 'D'])
df2 = pd.DataFrame(df1, index=dates, columns=['A', 'B', 'C', 'D', 'E', 'F'])
s1 = pd.Series([3, 4, 6, 7], index=dates[:4])  # 对第一个到第四个数据进行赋值
s2 = pd.Series([32, 5, 2, 1], index=dates[2:])  # 对第三个数据到最后一个数据进行赋值
df2['E'] = s1
df2['F'] = s2
print(df2)

关于“python中的pandas怎么安装使用”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“python中的pandas怎么安装使用”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI