Pandas基础

Pandas

一、文档

https://pandas.pydata.org/docs/getting_started/index.html#getting-started

https://pandas.pydata.org/docs/reference/frame.html

python数据分析之pandas数据选取:df[] df.loc[] df.iloc[] df.ix[] df.at[] df.iat[]

https://www.cnblogs.com/chenhuabin/archive/2019/03/06/10485549.html

二、安装pandas 

2.1 安装指令

conda install -c conda-forge pandas
//or
pip install pandas
# 如网络慢,可指定国内源快速下载安装
pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
2.2 镜像下载
Miniconda:
https://docs.conda.io/en/latest/miniconda.html
https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/
Anaconda:
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
2.3切换环境
# 查看所有虚拟环境及当前环境
conda info -e
# 创建新环境,指定环境名称和Python版本
conda create -n py38data python=3.8
# 删除环境
conda remove -n py38data --all
# 进入、激活环境
conda activate py38data
# 退出环境
conda deactivate

2.4 pip

pip list:# 查看当前Python环境安装了哪些库。
pip install 库名: # 安装新库,注意三个词之间要用空格隔开。
pip install库名1库名2库名3:# 同时安装多个库,多个库名之间用
空格隔开。
pip install库名-U:#将库的版本升级到最新版。
pip uninstall库名:# 卸载库。
pip install 库名 -i https://pypi.tuna.tsinghua.edu.cn/simple
# 安装Jupyter Notebook,使用清华大学下载源加快下载速度
pip install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple
# 安装 Jupyter Lab 的命令如下
pip install jupyterlab

2.5 Jupyter Notebook

Jupyter(https://jupyter.org)的特点是能够在网页上直接执行编写的代码,同时支持动态交互,在做数据可视化时尤其方便。
Jupyter Lab和Jupyter Notebook:Jupyter Lab为最新一代的产品。推荐安装Jupyter Notebook。

三、指令

Excel处理相关包:xlrd、openpyxl、XlsxWriter
解析网页包:Requests、lxml、html5lib、Beautiful Soup 4
可视化包:Matplotlib、seaborn、Plotly、Bokeh
计算包:SciPy、statsmodels
class pandas.Series(data=None, index=None, dtype=None, name=None, copy=None, fastpath=_NoDefault.no_default)
class pandas.DataFrame(data=None, index=None, columns=None, dtype=None, copy=None)
df.shape # (100, 6) 查看行数和列数
df.info() # 查看索引、数据类型和内存信息
df.describe() # 查看数值型列的汇总统计
df.dtypes # 查看各字段类型
df.axes # 显示数据行和列名
df.columns # 列名
df.sample(5)  # 随机查看5条
 
 
 
 
posted @ 2023-02-02 18:51  尘恍若梦  阅读(13)  评论(0编辑  收藏  举报