Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c5f159c

Browse files
Update 06-数据汇总.md
1 parent 603b73b commit c5f159c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

‎06-数据汇总.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ copydf = copydf.drop(copydf[copydf['a']< botrange].index)
122122
# 数据透视表
123123
pd.pivot_table(df_inner,index=['city'],values=['price'],columns=['gender'], \
124124
aggfunc=[len,np.sum], fill_value=0, margins=True)
125+
# 文本变量取最后一个值
126+
pd.pivot_table(df_inner, index=['gender'], values=['city'], aggfunc='last')
125127

126128
import datetime
127129
df = pd.DataFrame({'A': ['one', 'one', 'two', 'three'] * 6,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /