最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Pandas按周/月/年統(tǒng)計數(shù)據(jù)介紹

 更新時間:2021年12月14日 10:08:00   作者:小旺不正經(jīng)  
大家好,本篇文章主要講的是Pandas按周/月/年統(tǒng)計數(shù)據(jù)介紹,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽

Pandas 按周、月、年、統(tǒng)計數(shù)據(jù)

介紹

將日期轉(zhuǎn)為時間格式 并設(shè)置為索引

import pandas as pd
data=pd.read_excel('5\TB201812.xls',usecols=['訂單創(chuàng)建時間','總金額'])
print(data)
data['訂單創(chuàng)建時間']=pd.to_datetime(data['訂單創(chuàng)建時間'])
data=data.set_index('訂單創(chuàng)建時間')
print(data)

image-20211212113513921

按周、月、季度、年統(tǒng)計數(shù)據(jù)

import pandas as pd
data=pd.read_excel('5\TB201812.xls',usecols=['訂單創(chuàng)建時間','總金額'])
data['訂單創(chuàng)建時間']=pd.to_datetime(data['訂單創(chuàng)建時間'])
data=data.set_index('訂單創(chuàng)建時間')
print(data.resample('w').sum())
print(data.resample('m').sum())
print(data.resample('Q').sum())
print(data.resample('AS').sum())

image-20211212113905454

image-20211212113915052

使用to_period()方法 優(yōu)化

按月、季度和年顯示數(shù)據(jù)(不統(tǒng)計數(shù)據(jù))

import pandas as pd
data=pd.read_excel('5\TB201812.xls',usecols=['訂單創(chuàng)建時間','總金額'])
data['訂單創(chuàng)建時間']=pd.to_datetime(data['訂單創(chuàng)建時間'])
data=data.set_index('訂單創(chuàng)建時間')
print(data.resample('w').sum().to_period('w'))
print(data.resample('m').sum().to_period('m'))
print(data.resample('q').sum().to_period('q'))
print(data.resample('as').sum().to_period('a'))

image-20211212114219970

image-20211212114235410

與之前相比 日期的顯示方式發(fā)生了改變

到此這篇關(guān)于Pandas按周/月/年統(tǒng)計數(shù)據(jù)介紹的文章就介紹到這了,更多相關(guān)Pandas統(tǒng)計數(shù)據(jù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

武邑县| 长顺县| 澄城县| 绥中县| 台东县| 新蔡县| 庄河市| 文昌市| 乌海市| 怀远县| 兴宁市| 临澧县| 梁河县| 灵武市| 三亚市| 怀集县| 罗定市| 克拉玛依市| 扶余县| 安宁市| 宣化县| 阜城县| 都江堰市| 共和县| 榕江县| 洪江市| 当涂县| 鄯善县| 南京市| 周至县| 灵璧县| 县级市| 通河县| 平利县| 阆中市| 额济纳旗| 营山县| 峡江县| 抚顺市| 潜江市| 容城县|