Ich habe eine Pandas-Serie:
Code: Select all
email
[email protected] [1.0, 0.0, 0.0]
[email protected] [2.0, 0.0, 0.0]
[email protected] [1.0, 0.0, 0.0]
[email protected] [4.0, 0.0, 0.0]
[email protected] [1.0, 0.0, 3.0]
[email protected] [1.0, 5.0, 0.0]
Und ich möchte es in den folgenden DataFrame umwandeln:
Code: Select all
index | email | list
_____________________________________________
0 | [email protected] | [1.0, 0.0, 0.0]
1 | [email protected] | [2.0, 0.0, 0.0]
2 | [email protected] | [1.0, 0.0, 0.0]
3 | [email protected] | [4.0, 0.0, 0.0]
4 | [email protected] | [1.0, 0.0, 3.0]
5 | [email protected] | [1.0, 5.0, 0.0]
Ich habe einen Weg gefunden, es zu tun, aber ich bezweifle, dass es der effizientere ist:
Code: Select all
df1 = pd.DataFrame(data=sf.index, columns=['email'])
df2 = pd.DataFrame(data=sf.values, columns=['list'])
df = pd.merge(df1, df2, left_index=True, right_index=True)
Ich habe eine Pandas-Serie:
[code]email
[email protected] [1.0, 0.0, 0.0]
[email protected] [2.0, 0.0, 0.0]
[email protected] [1.0, 0.0, 0.0]
[email protected] [4.0, 0.0, 0.0]
[email protected] [1.0, 0.0, 3.0]
[email protected] [1.0, 5.0, 0.0]
[/code]
Und ich möchte es in den folgenden DataFrame umwandeln:
[code]index | email | list
_____________________________________________
0 |
[email protected] | [1.0, 0.0, 0.0]
1 |
[email protected] | [2.0, 0.0, 0.0]
2 |
[email protected] | [1.0, 0.0, 0.0]
3 |
[email protected] | [4.0, 0.0, 0.0]
4 |
[email protected] | [1.0, 0.0, 3.0]
5 |
[email protected] | [1.0, 5.0, 0.0]
[/code]
Ich habe einen Weg gefunden, es zu tun, aber ich bezweifle, dass es der effizientere ist:
[code]df1 = pd.DataFrame(data=sf.index, columns=['email'])
df2 = pd.DataFrame(data=sf.values, columns=['list'])
df = pd.merge(df1, df2, left_index=True, right_index=True)
[/code]