python-pandas的基本用法04
2017-08-06 10:57
501 查看
pandas的基本用法04-drop()
# -*- coding: utf-8 -*- import numpy as np from pandas import Series, DataFrame from numpy.core.defchararray import index from matplotlib.pyplot import axis s = Series(np.arange(5.), index=[1,2,3,4,5]) newS = s.drop([1,3]) print newS # 2 1 # 4 3 # 5 4 # dtype: float64 print 'DataFrame删除元素,可指定索引或列。' df = DataFrame(np.arange(16).reshape(4,4), index = ['a','b','c','d'], columns=[1,2,3,4] ) print df # 1 2 3 4 # a 0 1 2 3 # b 4 5 6 7 # c 8 9 10 11 # b 12 13 14 15 print df.drop(['a', 'b']) #闭区间 ['a','b'] # 1 2 3 4 # c 8 9 10 11 # d 12 13 14 15 print df.drop([1,2], axis=1) # 3 4 # a 2 3 # b 6 7 # c 10 11 # d 14 15
相关文章推荐
- 7064-1.Python数据分析:pandas基本用法(上)
- python-pandas的基本用法11
- python-pandas的基本用法05
- python-pandas的基本用法06
- Python基础(二)pandas基本用法
- python-pandas的基本用法03
- python-pandas的基本用法12
- 7064-2.Python数据分析:pandas基本用法(下)
- python-pandas的基本用法02
- python-pandas的基本用法07
- python-pandas的基本用法09
- python-pandas的基本用法10
- python-pandas的基本用法08
- 10分钟了解Pandas基本用法
- Python中list,tuple,dict,set基本定义和基本用法
- $ python-json模块的基本用法
- 好玩的分词——python jieba分词模块的基本用法
- selenium webdriver (python)的基本用法一
- python正则表达式--基本用法和函数(简单实例)
- Python爬虫(2):Requests的基本用法