Created
May 2, 2019 07:56
-
-
Save Everfighting/49ddb478494a887eb9da0c81ee57b5ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
可以用pandas里面的map映射字典。 | |
In [1]: import pandas as pd | |
In [2]: df = pd.DataFrame({'A':['AAAI','ICDM','SDM','WWW','KDD'], | |
'B':[0.88, 0.41,0.22, 0.33, 0.35]}) | |
In [3]: type_dict = {"AAAI":"AI","ICDM":"DM","SDM":"DM","KDD":"DM","WWW":"NEW"} | |
In [4]: df["C"] = df['A'].map(type_dict) | |
In [5]: df | |
Out[5]: | |
A B C | |
0 AAAI 0.88 AI | |
1 ICDM 0.41 DM | |
2 SDM 0.22 DM | |
3 WWW 0.33 NEW | |
4 KDD 0.35 DM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment