0
改變字符串二進制列
代碼:我如何能在大熊貓
import pandas as pd
df = pd.DataFrame(columns=['home_team', 'away_team'])
df = df.append(pd.Series(['a', 'b'], index=['home_team', 'away_team']), ignore_index=True)
df = df.append(pd.Series(['d', 'c'], index=['home_team', 'away_team']), ignore_index=True)
df = df.append(pd.Series(['c', 'd'], index=['home_team', 'away_team']), ignore_index=True)
df = df.append(pd.Series(['b', 'a'], index=['home_team', 'away_team']), ignore_index=True)
print(df)
原始數據幀:
home_team away_team
0 a b
1 d c
2 c d
3 b a
我想將它轉換爲:
bit0 bit1 bit2 bit3
0 0 0 0 1
1 1 1 1 0
2 1 0 1 1
3 0 1 0 0
"""
a:00
b:01
c:10
d:11
"""
a,b,c,d是隊名,例如'Real Madrid'\t,'La Coruna','Zaragoza',\t'特內里費'。我想在一列中找到一點。 – also
@also你應該如何解析你自己的方式.. –
我明白了。謝謝! – also