Pandas两种数据类型(jupyter)

import pandas as pd
import numpy as np
# pandas基本数据结构
# Series 一维数组,与numpy中的一维array相似,二者与pyhton列表也相近。Series能保存不同数据类型,字符串,boolean值,数字等都能保存在series中
# Dateframe 二维的表格型数据结构。很多功能与R中date.frame类似。可以将DateFrame理解为Series的容器。以下的内容主要以DateFrame为主

# Series
# 一维Series可以用一维列表初始化; 索引可以自己设置
s = pd.Series([1,2,3])
'''0    1
   1    2
   2    3
   dtype: int64'''
s = pd.Series([1,2,4],index =['a','b','c'])
'''a    1
   b    2
   c    4
   dtype: int64'''
# 当使用其他字符作为索引时,切片操作为双闭合,两边端点元素都要取
# 查看数据索引:行标签
s.index  # Index(['a', 'b', 'c'], dtype='object')
s.values  # array([1, 2, 4], dtype=int64)
# 索引赋值
s.index.name='索引'
'''索引
   a    1
   b    2
   c    4
   dtype: int64'''
s.index=list('012')
'''0    1
   1    2
   2    3
   dtype:
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值