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 d5118e3

Browse files
Update 04-数据预处理.md
1 parent 78c9fe8 commit d5118e3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

‎04-数据预处理.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ df['group'] = np.where(df['price'] > 3000, 'high', 'low')
110110
df['sign'] = 0
111111
df.loc[(df['city'] == 'beijing') & (df['price'] >= 4000), 'sign'] = 1
112112

113+
# 跨列判断
114+
df['province_match'] = df.apply(lambda x: x.province1.lower() == x.province2.lower(),axis=1)
115+
df['province_match'] = df['province_match'].astype('int')
116+
113117
# 数据分列与合并
114118
# 根据特殊符号、位置分列
115119
df['first_cat'] = df['category'].str.split('-', n=1).str[0]

0 commit comments

Comments
(0)

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