ich Pandas Datenrahmen mit Daten in einer sehr breiten Form habe ... zum Beispiel:Pandas - schmelzen, Stapel, neu zu gestalten oder Multiindex Datenrahmen Spalten basierend auf mehreren Attribute aus dem Spaltennamen
ID Equipment Function Task exprt_cond1_time exprt_cond2_time exprt_cond1_freq exprt_cond2_freq novce_cond1_time novce_cond2_time novce_cond1_freq novce_cond2_freq
0 eq_type_1 Fxn_a task_1 12 24 0.031 0.055 15 31 0.042 0.059
1 eq_type_1 Fxn_a task_2 10 22 0.028 0.052 12 29 0.039 0.055
2 eq_type_1 Fxn_b task_3 13 25 0.033 0.057 18 34 0.047 0.062
3 eq_type_1 Fxn_b task_4 9 19 0.027 0.051 10 28 0.038 0.054
4 eq_type_2 Fxn_a task_1 14 27 0.036 0.056 16 32 0.043 0.061
5 eq_type_2 Fxn_a task_2 11 26 0.030 0.054 14 30 0.041 0.058
aber ich bin mit dem Text in der Spaltenbeschriftung wandeln es in eine ordentlich lange Format wollen neue Spalten machen ... zB Daten aus der ersten und letzten Zeilen aus der oben könnte etwas mehr wie folgt aussehen:
ID Equipment Function Task Experience Condition Time Freq
0 eq_type_1 Fxn_a task_1 expert cond1 12 0.031
1 eq_type_1 Fxn_a task_1 expert cond2 24 0.055
2 eq_type_1 Fxn_a task_1 novice cond1 15 0.042
3 eq_type_1 Fxn_a task_1 novice cond2 31 0.059
...
16 eq_type_2 Fxn_a task_2 expert cond1 11 0.030
17 eq_type_2 Fxn_a task_2 expert cond2 26 0.054
18 eq_type_2 Fxn_a task_2 novice cond1 14 0.041
19 eq_type_2 Fxn_a task_2 novice cond2 30 0.058
Ich kann die richtige Kombination von Schmelze/Stapel/Umformen/MultiIndex oder othe nicht herausfinden r Übersetzungsfunktionen, um dies effizient zu machen, oder ohne dass mein Code hässlich wird, unhandlich, & fast unlesbar. This question und this question sind in der Nähe und helfen mir einige, aber sie scheinen nur basierend auf einem einzelnen Attribut in der Bezeichnung zu konvertieren. Ich würde jede Hilfe oder Tipps von der SO-Community lieben!
froh, dass meine Gunst Funktion zeigen, um zu sehen! :) – Wen
Schön! so sauber, auch :) – CJH