This is the example of my dataset.
JavaScript
x
10
10
1
>>> user1 = pd.read_csv('dataset/1.csv')
2
>>> print(user1)
3
0 0.69464 3.1735 7.5048
4
0 0.030639 0.14982 3.48680 9.2755
5
1 0.069763 -0.29965 1.94770 9.1120
6
2 0.099823 -1.68890 1.41650 10.1200
7
3 0.129820 -2.17930 0.95342 10.9240
8
4 0.159790 -2.30180 0.23155 10.6510
9
5 0.189820 -1.41650 1.18500 11.0730
10
How to push down the first column and add the names column [TIME, X, Y, and Z] on the first column.
The desired output is like this:
JavaScript
1
9
1
TIME X Y Z
2
0 0 0.69464 3.1735 7.5048
3
1 0.030639 0.14982 3.48680 9.2755
4
2 0.069763 -0.29965 1.94770 9.1120
5
3 0.099823 -1.68890 1.41650 10.1200
6
4 0.129820 -2.17930 0.95342 10.9240
7
5 0.159790 -2.30180 0.23155 10.6510
8
6 0.189820 -1.41650 1.18500 11.0730
9
Advertisement
Answer
I’d do it like this:
JavaScript
1
3
1
colnames=['TIME', 'X', 'Y', 'Z']
2
user1 = pd.read_csv('dataset/1.csv', names=colnames, header=None)
3