好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > Pandas讀取行列數(shù)據(jù)最全方法

Pandas讀取行列數(shù)據(jù)最全方法

熱門標(biāo)簽:西青語音電銷機(jī)器人哪家好 電梯新時達(dá)系統(tǒng)外呼顯示e 宿州電話機(jī)器人哪家好 無錫智能外呼系統(tǒng)好用嗎 地圖標(biāo)注與注銷 南昌地圖標(biāo)注 旅游廁所地圖標(biāo)注怎么弄 百應(yīng)電話機(jī)器人總部 成都呼叫中心外呼系統(tǒng)哪家強(qiáng)

1、讀取方法有按行(單行,多行連續(xù),多行不連續(xù)),按列(單列,多列連續(xù),多列不連續(xù));部分不連續(xù)行不連續(xù)列;按位置(坐標(biāo)),按字符(索引);按塊(list);函數(shù)有 df.iloc(), df.loc(), df.iat(), df.at(), df.ix()。

2、轉(zhuǎn)換為DF,賦值columns,index,修改添加數(shù)據(jù),取行列索引

data = {'省份': ['北京', '上海', '廣州', '深圳'],
        '年份': ['2017', '2018', '2019', '2020'],
        '總?cè)藬?shù)': ['2200', '1900', '2170', '1890'],
        '高考人數(shù)': ['6.3', '5.9', '6.0', '5.2']}
df = pd.DataFrame(data, columns=['省份', '年份', '總?cè)藬?shù)', '高考人數(shù)', '高數(shù)'],
                  index=['one', 'two', 'three', 'four'])
df['高數(shù)'] = ['90', '95', '92', '98']
print("行索引:{}".format(list(df.index)))
print("列索引:{}".format(list(df.columns)))
print(df.index[1:3])
print(df.columns[1])
print(df.columns[1:3])
print(df)

行索引:['one', 'two', 'three', 'four']
列索引:['省份', '年份', '總?cè)藬?shù)', '高考人數(shù)', '高數(shù)']
Index(['two', 'three'], dtype='object')
年份
Index(['年份', '總?cè)藬?shù)'], dtype='object')
       省份    年份   總?cè)藬?shù) 高考人數(shù)  高數(shù)
one    北京  2017  2200  6.3  90
two    上海  2018  1900  5.9  95
three  廣州  2019  2170  6.0  92
four   深圳  2020  1890  5.2  98

3、iloc不能通過[:, [1:3]]取連續(xù)數(shù)據(jù),取連續(xù)數(shù)據(jù)只能通過 df[df.columns[1:4]],先獲取列索引,再取數(shù)據(jù)。

print(df['省份'])  #按列名取列
print(df.省份)  #按列名取列
print(df[['省份', '總?cè)藬?shù)']])  #按列名取不連續(xù)列數(shù)據(jù)
print(df[df.columns[1:4]])  #按列索引取連續(xù)列數(shù)據(jù)
print(df.iloc[:, 1])  #按位置取列
print(df.iloc[:, [1, 3]])  #按位置取不連續(xù)列數(shù)據(jù)

one      北京
two      上海
three    廣州
four     深圳
Name: 省份, dtype: object
one      北京
two      上海
three    廣州
four     深圳
Name: 省份, dtype: object
       省份   總?cè)藬?shù)
one    北京  2200
two    上海  1900
three  廣州  2170
four   深圳  1890
         年份   總?cè)藬?shù) 高考人數(shù)
one    2017  2200  6.3
two    2018  1900  5.9
three  2019  2170  6.0
four   2020  1890  5.2
one      2017
two      2018
three    2019
four     2020
Name: 年份, dtype: object
         年份 高考人數(shù)
one    2017  6.3
two    2018  5.9
three  2019  6.0
four   2020  5.2

4、通過df.iloc[](數(shù)字)取行數(shù)據(jù),取部分行部分列時,要先寫行,再寫列;有條件的取數(shù)據(jù)

print(df[1:3])  #按行取數(shù)據(jù),這行代碼結(jié)果沒在下面輸出
print(df[df.高數(shù)>90])  #按行有條件的取數(shù)據(jù),結(jié)果沒輸出
print(df.iloc[1])  #按行取行數(shù)據(jù)
print(df.iloc[1, 3])  #按坐標(biāo)取
print(df.iloc[[1], [3]])  #按坐標(biāo)取
print(df.loc[df.index[1:3]])  #按行索引取行,但沒必要
print(df.iloc[1:3])  #按行取連續(xù)數(shù)據(jù)
print(df.iloc[[1, 3]])  按行取不連續(xù)數(shù)據(jù)
print(df.iloc[[1,2,3], [2,4]])  取部分行部分列數(shù)據(jù)

省份        上海
年份      2018
總?cè)藬?shù)     1900
高考人數(shù)     5.9
高數(shù)        95
Name: two, dtype: object
5.9
    高考人數(shù)
two  5.9
       省份    年份   總?cè)藬?shù) 高考人數(shù)  高數(shù)
two    上海  2018  1900  5.9  95
three  廣州  2019  2170  6.0  92
       省份    年份   總?cè)藬?shù) 高考人數(shù)  高數(shù)
two    上海  2018  1900  5.9  95
three  廣州  2019  2170  6.0  92
      省份    年份   總?cè)藬?shù) 高考人數(shù)  高數(shù)
two   上海  2018  1900  5.9  95
four  深圳  2020  1890  5.2  98
        總?cè)藬?shù)  高數(shù)
two    1900  95
three  2170  92
four   1890  98

5、通過df.loc[]索引(字符)取行數(shù)據(jù)。

print(df.loc['two'])
print(df.loc['two', '省份'])
print(df.loc['two':'three'])
print(df.loc[['one', 'three']])
print(df.loc[['one', 'three'], ['省份', '年份']])

省份        上海
年份      2018
總?cè)藬?shù)     1900
高考人數(shù)     5.9
高數(shù)        95
Name: two, dtype: object
上海
       省份    年份   總?cè)藬?shù) 高考人數(shù)  高數(shù)
two    上海  2018  1900  5.9  95
three  廣州  2019  2170  6.0  92
       省份    年份   總?cè)藬?shù) 高考人數(shù)  高數(shù)
one    北京  2017  2200  6.3  90
three  廣州  2019  2170  6.0  92
       省份    年份
one    北京  2017
three  廣州  2019

6、ix,iat,at取行列數(shù)據(jù),此方法不常用,可以使用上面方法即可。

print(df.ix[1:3])
print(df.ix[:, [1, 3]])
print(df.iat[1,3])
print(df.at['two', '省份'])

       省份    年份   總?cè)藬?shù) 高考人數(shù)  高數(shù)
two    上海  2018  1900  5.9  95
three  廣州  2019  2170  6.0  92
         年份 高考人數(shù)
one    2017  6.3
two    2018  5.9
three  2019  6.0
four   2020  5.2
5.9
上海

到此這篇關(guān)于Pandas讀取行列數(shù)據(jù)最全方法的文章就介紹到這了,更多相關(guān)Pandas讀取行列 內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • pandas 轉(zhuǎn)換成行列表進(jìn)行讀取與Nan處理的方法
  • pandas Dataframe行列讀取的實(shí)例

標(biāo)簽:辛集 濰坊 渭南 七臺河 雅安 贛州 許昌 西安

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Pandas讀取行列數(shù)據(jù)最全方法》,本文關(guān)鍵詞  Pandas,讀取,行列,數(shù)據(jù),最全,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Pandas讀取行列數(shù)據(jù)最全方法》相關(guān)的同類信息!
  • 本頁收集關(guān)于Pandas讀取行列數(shù)據(jù)最全方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 国产精品h| 国产精品伦一区二区三级古装电影 | 男人透女人超爽视频免费| 两性午夜视频一区二区| 亚洲精品无码影视一二三四| 蜜桃社缇娜美全套无圣光| 男男做爰猛烈啪啪高| XXOO亚洲AV成人片| 琪琪色影音先锋| 歪歪漫画每周限免| 快点用力| 影音先锋5566一区二区| 国产又色又爽又黄刺激的影视| 欧美bbw性色大片试看| 日韩精品一区二区三区在线观看l| 美女被爆羞羞软件| 国产??在线观看免费视频| 国产三级精品美女三级| 亚洲黄色大片| 激情床片段视频| 曰本美女毛片XXXXXXXXX| 农村老头olddaytv| 性夜夜春夜夜爽A片欧美| 激情影院adc| 日本动漫无码??有限公司| 国产精品久久久久久久电影渣男| 啊轻点灬大ji巴太粗太长了在| 把女人的下面扒开添干净| 尤物视频一区| 日在校园免费观看| 国产精品51麻豆cm传媒的特点 | 人人看人人插| 扒开双腿疯狂进出爽h男男视频 | 大尺度吸舌湿吻在线观看日本| 中国老太婆bbbbbxxxxx| 日本理论片午伦夜理片2021导演 | 嫩模尺度私拍在线视频| 香港三级日本三级三级韩| 黄色激情小说| 72式性无遮挡免费视频人伦| 一进一出一爽又粗又大毛片|