Reputation: 19
results=pd.DataFrame({"Picture":filenames,"predictions":predictions})
results.to_csv("/home/udas/scratch/projekt01/results.csv",index=False,header=None)
kf= pd.read_csv('/home/udas/scratch/projekt01/results.csv')
print(kf.head())
Why does my index begins at second row?
ROCO_CLEF_TEST_00001 C0034579;C0040405;C0556030;C0231519;C0240795;C0040395;C2347268;C1135564;C1963113;C3263723;C0043299;C0027530;C0376381;C1962945;C0845672;C0524865;C1293284;C0841296;C2985765;C0565460;C0220825;C0041618;C0000726;C0023884;C0441513;C3203359;C1553386;C0005682;C0868996;C1293304
0 ROCO_CLEF_TEST_00002 C0441633;C0227665;C0022646;C0000726;C0034579;C...
1 ROCO_CLEF_TEST_00003 C1963113;C2713294;C1962945;C0043299;C1548003;C...
2 ROCO_CLEF_TEST_00004 C0222682;C0018563;C0043299;C1962945;C1548003;C...
3 ROCO_CLEF_TEST_00005 C0034579;C0040395;C0040405;C1293304;C0524865;C...
4 ROCO_CLEF_TEST_00006 C0018827;C0013516;C0183129;C2355627;C0203378;C...
Can anyone help to solve it?
Upvotes: 1
Views: 59
Reputation: 1430
Here you save without header:
results.to_csv("/home/udas/scratch/projekt01/results.csv",index=False,header=None)
But here you read with assumptation that header exists, so first row of data is used for header:
kf= pd.read_csv('/home/udas/scratch/projekt01/results.csv')
So two options, either :
A) results.to_csv("/home/udas/scratch/projekt01/results.csv",index=False)
or:
B) kf= pd.read_csv('/home/udas/scratch/projekt01/results.csv', header=0)
Upvotes: 1