data frame

Val Krem valkrem at yahoo.com
Sat Dec 24 10:37:52 EST 2016


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 <__peter__ at 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
> 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, 26
123, 250, 34
...

>     a=pd.read_csv("s1.csv", skipinitialspace=True).keys()

You should use the keys() method call for diagnosis only. The final script 
that might work if your problem is actually space after the commas is

import pandas as  pd

a = pd.read_csv("s1.csv", skipinitialspace=True)
a["test"] = a["h1"] + a["w1"]
print(a)


-- 
https://mail.python.org/mailman/listinfo/python-list


More information about the Python-list mailing list