我有一个大约16000个条目和12列的数据框。我(希望)已经删除了重复项和Nan值。 我想在一个带有熊猫的饼图中,形象化“品牌”一栏中出现的次数。但每一个出现次数少于20次的品牌都应该被归为“Freie Tankstellen”
我已经做到了:
df_stations['brand'].value_counts().to_frame()< 20
但我不知道如何进行,提前谢谢你
elias_lay___schisslbauer_simon2021-06-12_11-57-Jupyter笔记本
,uuid,name,brand,street,house_number,post_code,city,latitude,longitude,first_active,openingtimes_json,state,istFrei
0,0e18d0d3-ed38-4e7f-a18e-507a78ad901d,OIL! Tankstelle München,OIL!,EVERSBUSCHSTRASSE,33,80999,MÜNCHEN,48.1807,11.4609,1970-01-01 01:00:00+01,"{""openingTimes"":[{""applicable_days"":192,""periods"":[{""startp"":""07:00"",""endp"":""20:00""}]},{""applicable_days"":63,""periods"":[{""startp"":""06:00"",""endp"":""22:00""}]}]}",Bayern,True
1,44e2bdb7-13e3-4156-8576-8326cdd20459,bft Tankstelle,BFT TANKSTELLE,SCHELLENGASSE ,53,36304,ALSFELD,50.7520089,9.2790394,1970-01-01 01:00:00+01,"{""openingTimes"":[{""applicable_days"":63,""periods"":[{""startp"":""06:00"",""endp"":""22:00""}]},{""applicable_days"":64,""periods"":[{""startp"":""07:00"",""endp"":""21:00""}]}]}",Hessen,True
2,ad812258-94e7-473d-aa80-d392f7532218,bft Bonn-Bad Godesberg,BFT,GODESBERGER ALLEE,55,53175,BONN,50.6951,7.14276,1970-01-01 01:00:00+01,"{""openingTimes"":[{""applicable_days"":31,""periods"":[{""startp"":""06:00"",""endp"":""22:00""}]},{""applicable_days"":32,""periods"":[{""startp"":""07:00"",""endp"":""22:00""}]},{""applicable_days"":64,""periods"":[{""startp"":""08:00"",""endp"":""22:00""}]}]}",Nordrhein-Westfalen,True
df.brand.value_counts()
可以使用.merge
将'total_count'
列添加到df
李>'brand'
的'total_count'
小于.lt
,20的'brand'
李>'brand'
获取新的.value_counts
,并使用pandas.DataFrame.plot
和kind='barh'
绘制一个水平条。如果品牌不多,请使用kind='bar'
并更改figsize
kind='pie'
可以使用,但是,虽然我喜欢pi
和饼图,但我不喜欢或推荐pie
图表。pandas v1.2.4
和matplotlib v3.4.2
与
kind='pie'
相比相关问题 更多 >
编程相关推荐