Erweitern Sie den Datenrahmen und sortieren Sie dann basierend auf der Wertereihenfolge in der ersten Zeile

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Erweitern Sie den Datenrahmen und sortieren Sie dann basierend auf der Wertereihenfolge in der ersten Zeile

by Anonymous » 17 Mar 2025, 15:02

Suppose I have a dataframe with the following format of strings separated by commas:



index
columnName




0
apple,peach,orange,pear,


1
orange, pear,apple


2
pear


3
peach,apple


4
orange < /td>
< /tr>
< /tbody>
< /table> < /div>
Die tatsächlichen Zahlenreihen sind größer als 10.000. NoneType:



index
0
1
2
3
< /tr>
< /thead>


0 < /td>
Apfel < /td>
Peach < /td>
< /th> < /td>

pein />
1
apple
None
orange
pear


2
None
None
None
pear


3
apple
peach
None
None


4
None
None
orange
None
< /tr>
< /tbody>
< /table> < /div>
Ich habe die Daten < /p>
erweitert.

Code: Select all

df= df['columnName'].str.split(',',expand=True) #expand initial dataframe
Ich kann die Daten nicht so sortieren/neu ordnen, obwohl verschiedene Kombinationen von df.sort_values ​​() .>

Top