Hauptmenü
(0, 'Information')
(1, 'Beenden')
(2, 'Hilfe')
(3, 'Trennzeichen')
(4, 'Lesen')
(5, 'csv_suche')
Option: bitte einen Menüpunkt eingeben: Information
Version : 1.0
Datum der letzten Version : 04.01.2020
(0, 'Information')
(1, 'Beenden')
(2, 'Hilfe')
(3, 'Trennzeichen')
(4, 'Lesen')
(5, 'csv_suche')
Option: bitte einen Menüpunkt eingeben:
我的出场在下面
df_n_gender_grp = df_n_gender_prod_cat.groupby(['Gender','prod_cat'])
我的期望值是
第一个数据帧按值降序
Gender prod_cat
0 M Books
1 M Books
2 M Electronics
3 M Electronics
4 M Books
100 F Electronics
101 F Electronics
102 F Electronics
103 F Electronics
104 F Electronics
105 F Clothing
106 F Clothing
107 F Clothing
108 F Clothing
第二个数据帧,其值按降序排列
M Books 2
M Electronics 3
答案 0 :(得分:2)
与.tif
GroupBy.size
和Series.sort_index
一起用于> writeRaster(s, paste0(names(s),".tif"), bylayer=TRUE, format="GTiff")
:
> dir()
[1] "layer.1.tif" "layer.2.tif" "layer.3.tif" "layer.tif"
然后按Series
MultiIndex
对于DataFrame是必需的,请添加Series.reset_index
:
s = df_n_gender_prod_cat.groupby(['Gender','prod_cat']).size().sort_index(ascending=False)
print (s)
Gender prod_cat
M Electronics 2
Books 3
F Electronics 5
Clothing 4
dtype: int64
或先添加Series.reset_index
:
loc
然后按boolean indexing
进行过滤:
df1 = s.loc[['F']]
df2 = s.loc[['M']]