Help me: load data

Hi,

I have a load data problem.

code has an error:import numpy as np
import pandas as pd

1) Charger fichier

data = pd.read_csv(“Neuro2025_005_2025_11_25_Marker.txt”, sep=‘\t’, header=None)

2) Reshape en (time, 23 marqueurs, XYZ)

reshaped_data = data.values.reshape(-1, 23, 3)

3) Créer MultiIndex correct

Marker_columns = [f’M{i}’ for i in range(1, 24)] # 23 marqueurs
coordinate_columns = [‘X’, ‘Y’, ‘Z’]

columns = pd.MultiIndex.from_product(
[Marker_columns, coordinate_columns],
names=[‘Marker’, ‘Coordinate’]
)

4) Créer DataFrame final

reshaped_df = pd.DataFrame(
reshaped_data.reshape(-1, 23 * 3),
columns=columns
)

#print(reshaped_df.head())

print(data.head())
print(data.tail())
print(data.shape)

Data form is

Marker01_x Marker01_y Marker01_z Marker02_x Marker02_y Marker02_z Marker03_x Marker03_y Marker03_z
564.288 243.264 1599.64 667.957 133.241 1588.25 698.844 286.609 1588.39
564.288 243.264 1599.64 667.957 133.241 1588.25 698.844 286.609 1588.39
564.386 243.325 1599.73 668.207 133.037 1588.3 698.909 286.594 1588.32
564.515 243.027 1599.81 668.415 132.984 1588.36 698.823 286.464 1588.29
564.493 242.8 1599.91 668.418 133.055 1588.44 699.07 286.641 1588.25
564.683 242.808 1599.95 668.655 132.897 1588.49 699.011 286.676 1588.22
564.559 242.551 1600.08 668.718 133.045 1588.58 699.295 286.34 1588.22
565.064 242.409 1600.19 668.749 132.925 1588.58 699.163 286.674 1588.17
565.127 242.637 1600.23 668.993 132.779 1588.62 699.356 286.418 1588.15
564.936 242.699 1600.31 669.032 132.845 1588.63 699.155 286.451 1588.11
565.221 242.47 1600.37 669.224 132.798 1588.65 699.444 286.336 1588.12
565.268 242.359 1600.4 669.25 132.866 1588.64 699.428 286.289 1588.12
565.369 242.259 1600.5 669.403 132.745 1588.6 699.502 286.334 1588.14
565.352 242.411 1600.48 669.446 132.65 1588.61 699.467 286.383 1588.14
565.599 242.261 1600.53 669.471 132.773 1588.61 699.668 286.076 1588.19
565.607 242.388 1600.53 669.66 132.669 1588.57 699.66 286.205 1588.19
565.796 241.75 1600.51 669.725 132.678 1588.53 699.853 285.882 1588.26
565.981 242.263 1600.51 669.807 132.284 1588.46 699.714 286.219 1588.27
565.912 241.969 1600.48 669.909 132.364 1588.43 699.837 286.176 1588.32
565.725 241.852 1600.42 670.181 132.189 1588.36 699.86 286.015 1588.36
565.735 241.394 1600.34 670.227 132.169 1588.3 699.754 286.066 1588.42
565.843 241.503 1600.3 670.443 132.129 1588.25 699.902 285.872 1588.48
566.093 241.245 1600.3 670.432 132.078 1588.17 699.754 285.909 1588.54
566.01 241.212 1600.24 670.751 131.982 1588.12 699.885 285.841 1588.61
566.089 241.174 1600.23 670.854 131.866 1588.05 699.835 285.9 1588.66

Have you tried running this with Python without involving Jupyter? I suspect you’d get the same result, which means it is likely not a Jupyter issue and therefore this is not pertinent to this forum.

The big issue for wherever you end up posting is that you say it has an error and there is no error provided.

Please read and use Getting good answers to your questions as a guide to posting in this forum and related ones.
And please look at other examples of posted code here. You want to make it so others can just paste it in and run it. To help you with that see about ‘block code formatting’ here. (Or see about ‘fenced code blocks’ here. They are both the same thing if you look into the details.

1 Like