If you have a csv-file file.csv
0,0
2,0
4,0
1,1.732051
3,1.732051
then
df = pd.read_csv("file.csv", index_col=0)
does produce
df =
0.1
0
2 0.000000
4 0.000000
1 1.732051
3 1.732051
Why is that: There are two 0
s in the first row and Pandas is mangling the dupes because the row is used for labels. The 0.1
isn't a number, it's a string (print(df.columns)
will show Index(['0.1'], dtype='object')
). If your file would look like
0,1
2,0
4,0
1,1.732051
3,1.732051
then this wouldn't happen, the output would look like
1
0
2 0.000000
4 0.000000
1 1.732051
3 1.732051
If your goal is NumPy array, then
arr = pd.read_csv("file.csv", header=None).values
leads to
array([[0. , 0. ],
[2. , 0. ],
[4. , 0. ],
[1. , 1.732051],
[3. , 1.732051]])