pandas read_csv create columns based on value in one of the csv columns
<p>I have csv data that looks like this:</p>

<pre><code>1471361094509,doorLowerPosition,-73.3348875
1471361094509,doorUpperPosition,-3.29595
1471361094512,sectionLowerCurrFiltered,-0.2
1471361094512,actuatorLowerFrontDuty,0.0
1471361094515,doorCtrlStatus,5.0
1471361094515,SMState,14.0
1471361094516,lateralAccel,25.55
1471361094516,longitudinalAccel,25.55 
1471361094519,ambientTemperature,23.5
</code></pre>

<p>Which I would like to import into a DataFrame with the the leftmost value being the index, the middle a column identifier and the rightmost, the value for the column at that index.</p>

<p>Previously I was separating these and importing them manually, then joining into a single frame. I wonder if there is quicker way to do it in one step.</p>

<p>Read the data into a DataFrame using <code>pd.read_csv</code>, and then <a href="http://pandas.pydata.org/pandas-docs/stable/reshaping.html#reshaping-by-pivoting-dataframe-objects" rel="nofollow"><code>pivot</code></a>:</p>

<pre><code>import pandas as pd
df = pd.read_csv('data', header=None, names=['index','columns','value'])
df = df.pivot('index', 'columns', 'value')
print(df)
</code></pre>

<p>yields</p>

<pre><code>columns        SMState  actuatorLowerFrontDuty  ambientTemperature  \
index                                                                
1471361094509      NaN                     NaN                 NaN   
1471361094512      NaN                     0.0                 NaN   
1471361094515     14.0                     NaN                 NaN   
1471361094516      NaN                     NaN                 NaN   
1471361094519      NaN                     NaN                23.5   

columns        doorCtrlStatus  doorLowerPosition  doorUpperPosition  \
index                                                                 
1471361094509             NaN         -73.334887           -3.29595   
1471361094512             NaN                NaN                NaN   
1471361094515             5.0                NaN                NaN   
1471361094516             NaN                NaN                NaN   
1471361094519             NaN                NaN                NaN   

columns        lateralAccel  longitudinalAccel  sectionLowerCurrFiltered  
index                                                                     
1471361094509           NaN                NaN                       NaN  
1471361094512           NaN                NaN                      -0.2  
1471361094515           NaN                NaN                       NaN  
1471361094516         25.55              25.55                       NaN  
1471361094519           NaN                NaN                       NaN  
</code></pre>

python pandas