日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

pandas Series DataFrame 丢弃指定轴上的项(三)

發布時間:2025/4/5 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pandas Series DataFrame 丢弃指定轴上的项(三) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.0 刪除Series項

from pandas import Series,DataFrame import numpy as np import pandas as pd obj=Series(np.arange(5),index=['a','b','c','d','e'])obj Out[82]: a 0 b 1 c 2 d 3 e 4 dtype: int32 new_obj=obj.drop('c')new_obj Out[84]: a 0 b 1 d 3 e 4 dtype: int32 obj=Series(np.arange(5),index=['a','b','c','d','e'])obj Out[90]: a 0 b 1 c 2 d 3 e 4 dtype: int32 obj.drop(['d','c']) Out[91]: a 0 b 1 e 4 dtype: int32

2.0 刪除DataFrame項

data=DataFrame(np.arange(16).reshape((4,4)),index=['ohio','colorado','utah','new york'],columns=['one','two','three','four'])data Out[94]: one two three four ohio 0 1 2 3 colorado 4 5 6 7 utah 8 9 10 11 new york 12 13 14 15

?? ??刪除 colorado 和ohio

data.drop(['colorado','ohio']) Out[95]: one two three four utah 8 9 10 11 new york 12 13 14 15 data.drop('two',axis=1) Out[98]: one three four ohio 0 2 3 colorado 4 6 7 utah 8 10 11 new york 12 14 15 data.drop(['two','four'],axis=1) Out[100]: one three ohio 0 2 colorado 4 6 utah 8 10 new york 12 14

總結

以上是生活随笔為你收集整理的pandas Series DataFrame 丢弃指定轴上的项(三)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。