I have been experimenting with pandas, and while I have figured out how to use it to read data, I have stumbled upon some trouble in writing my output, and need your help!
This is my simplified code:
import pandas as pd
df = pd.DataFrame("prices", "product1", "product2", "product3")
prices = df.prices
product1 = df.product1
product2 = df.product2
product3 = df.product3
prices = ["Price Option 1", "Price Option 2", "Price Option 3"]
product1 = [1,2,3]
product2 = [4,5,6]
product3 = [7,8,9]
df.to_csv("output.csv")
The expected output was supposed to be something like:
prices product1 product2 product3
price1 1 2 3
price2 4 5 6
price3 7 8 9
But instead I get this error:
Traceback (most recent call last):
File "output.py", line 3, in <module>
df = pd.DataFrame("prices", "product1", "product2", "product3")
File "C:\Python27\lib\site-packages\pandas-0.14.1-py2.7-win32.egg\pandas\core\frame.py", line 194,
in __init__
dtype = self._validate_dtype(dtype)
File "C:\Python27\lib\site-packages\pandas-0.14.1-py2.7-win32.egg\pandas\core\generic.py", line 10
8, in _validate_dtype
dtype = np.dtype(dtype)
TypeError: data type "product3" not understood
And I'm not quite sure why... Help is much appreciated!