data frame
Peter Otten
__peter__ at web.de
Fri Dec 23 18:24:46 EST 2016
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)
More information about the Python-list
mailing list