Spaces:
Build error
Build error
Commit ·
2a91262
1
Parent(s): 14ec4f5
Fix bug in dataframe
Browse files
utils.py
CHANGED
|
@@ -144,14 +144,14 @@ def empty_note_sequence(qpm=120, total_time=0.0):
|
|
| 144 |
|
| 145 |
# Generate piano_roll
|
| 146 |
def sequence_to_pandas_dataframe(sequence):
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
|
| 156 |
def dataframe_to_pianoroll_img(df):
|
| 157 |
fig = plt.figure(figsize=(8, 5))
|
|
|
|
| 144 |
|
| 145 |
# Generate piano_roll
|
| 146 |
def sequence_to_pandas_dataframe(sequence):
|
| 147 |
+
pd_dict = collections.defaultdict(list)
|
| 148 |
+
for note in sequence.notes:
|
| 149 |
+
pd_dict["start_time"].append(note.start_time)
|
| 150 |
+
pd_dict["end_time"].append(note.end_time)
|
| 151 |
+
pd_dict["duration"].append(note.end_time - note.start_time)
|
| 152 |
+
pd_dict["pitch"].append(note.pitch)
|
| 153 |
+
|
| 154 |
+
return pd.DataFrame(pd_dict)
|
| 155 |
|
| 156 |
def dataframe_to_pianoroll_img(df):
|
| 157 |
fig = plt.figure(figsize=(8, 5))
|