📗
deeplearning
  • 机器学习
    • LR & SVM
    • 树模型
    • 评测指标
    • 数据不平衡
  • CV基础
    • 基础模型
    • 初始化
    • 激活函数
    • 注意力机制
    • 损失函数
    • 优化器
    • 可视化
    • 轻量级网络
    • 多任务学习
  • deepfake
    • 数据集
  • 人脸
    • 数据集
    • 人脸对齐
    • 人脸检测
    • 人脸识别
  • 语义分割
    • 语义分割
  • 无监督
    • 无监督
  • 推荐系统
    • 推荐系统模型
    • 推荐系统中的偏差
    • 王喆:深度学习推荐系统
    • 特征处理
    • 重排序
    • 互联网商业化变现
  • 数学
    • bayes最大似然
    • 蒙特卡洛
  • 网站
    • css
    • html
    • js
    • jquery
    • flask
  • 基础工具
    • anaconda
    • docker
    • git
    • linux install
    • vpn
    • latex
  • python
    • numpy
    • matplotlib
    • pandas
    • multi process
    • pytorch
  • 设计模式
    • 设计模式之美
    • 图说设计模式
  • 其他
    • how to ask
    • python style
Powered by GitBook
On this page
  • Pandas一维数据结构:Series
  • Pandas二维数据结构:DataFrame

Was this helpful?

  1. python

pandas

PreviousmatplotlibNextmulti process

Last updated 3 years ago

Was this helpful?

Pandas一维数据结构:Series

Series 是一维带标记的数组结构,可以存储任意类型的数据(整数,浮点数,字符串,Python 对象等等)。

作为一维结构,它的索引叫做 index,基本调用方法为

s = pd.Series(data, index=index) 其中,data 可以是以下结构:字典、ndarray、标量(例如 5)。 index 是一维坐标轴的索引列表。

如果 data 是个 ndarray,那么 index 的长度必须跟 data 一致: s = pd.Series(np.random.randn(5), index=["a", "b", "c", "d", "e"])

pd.Series(np.random.randn(5))

简单的向量操作 series 与 ndarray 的表现一致,区别在于Series 的操作默认是使用 index 的值进行对齐的,而不是相对位置,对于两个不能完全对齐的 Series,结果的 index 是两者 index 的并集,同时不能对齐的部分当作缺失值处理。

Pandas二维数据结构:DataFrame

def write_list_to_csv(csv_path,index_list):
    test=pd.DataFrame(columns=None,data=index_list)
    test.to_csv(csv_path,mode='a+', header=False,index=False)

def read_csv_to_list(csv_path):
    return pd.read_csv(csv_path,header = None).values.tolist()

读取csv文件:df=pd.read_csv('test.csv',header='infer',sep=',')

Pandas官方-Pandas 10分钟入门
pandas索引和选择数据