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 155126f

Browse files
Update 07-常用函数.md
1 parent c026720 commit 155126f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎07-常用函数.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,22 @@ def mode_pct(L):
298298
a = df.groupby('id')['amount'].apply(mode_pct)
299299
```
300300

301+
<br/>
302+
303+
------
304+
305+
### 计算非空唯一值
306+
307+
```python
308+
def uni_cnt(list_x):
309+
list_x = [x for x in list_x if x != None]
310+
list_x = [x for x in list_x if x != np.nan]
311+
list_x = [x for x in list_x if x != '']
312+
return len(set(list_x))
313+
314+
a = pd.pivot_table(df, index=['Month'], values=['id'], aggfunc=nui_cnt)
315+
```
316+
301317

302318

303319
| [**< <目录**](./README.md) | [**返回顶部 ↑**](#07-常用函数) |

0 commit comments

Comments
(0)

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