Thank you Peter and Christ.
It is was a white space and the fix fixed it.
Many thanks.
On Friday, December 23, 2016 5:26 PM, Peter Otten <__pete...@web.de> wrote:
Val Krem via Python-list wrote:
> Here is the first few lines of the data
>
>
> s1.csv
> size,w1,h1
> 512,214,26
> 123,250,34
>
Val Krem via Python-list wrote:
> Here is the first few lines of the data
>
>
> s1.csv
> size,w1,h1
> 512,214,26
> 123,250,34
> 234,124,25
> 334,213,43
Did you put these lines here using copy and paste? The fix below depends on
the assumption that your data is more like
size, w1, h1
512, 214,
Here is the first few lines of the data
s1.csv
size,w1,h1
512,214,26
123,250,34
234,124,25
334,213,43
and the script
a=pd.read_csv("s1.csv", skipinitialspace=True).keys()
print(a)
i see the following
Index(['size', 'w1', 'h1'], dtype='object')
when I wanted to add the two columns;
Val Krem via Python-list wrote:
> Hi all,
>
> #!/usr/bin/env python
> import sys
> import csv
> import numpy as np
> import pandas as pd
>
> a= pd.read_csv("s1.csv")
> print(a)
>
> size w1 h1
> 0 512 214 26
> 1 123 250 34
> 2 234 124 25
> 3 334 213 43
> 4 a45 223 3
On Sat, Dec 24, 2016 at 7:39 AM, Val Krem via Python-list
wrote:
> a= pd.read_csv("s1.csv")
> File "pandas/src/hashtable_class_helper.pxi", line 740, in
> pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:13107)
> KeyError: 'w1'
>
> Can someone help me what the problem is?
Can you