Upload data from csv to series in python
<p>I have a data in a column in a csv format and want to append it in series in python that it can be displayed like:</p>

<pre><code>series=[12,13,12,22,34,21]
</code></pre>

<p>How can it be done? Should I do it via read_csv and then somehow transform it to series or it is a another way?</p>

<p>Thanks!</p>

<p>IIUC and you are talking about pandas - you can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow">squeeze</a> parameter:</p>

<pre><code>In [86]: import pandas as pd

In [87]: s = pd.read_csv('d:/temp/.data/1.csv', header=None, squeeze=True)

In [88]: s
Out[88]:
0    12
1    13
2    12
3    22
4    34
5    21
Name: 0, dtype: int64
</code></pre>

<p>as a vanilla Python list:</p>

<pre><code>In [89]: s.tolist()
Out[89]: [12, 13, 12, 22, 34, 21]
</code></pre>

<p>from <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow">docs</a>:</p>

<blockquote>
  <p><strong>squeeze</strong> : boolean, default False</p>
  
  <p>If the parsed data only contains one column then return a Series</p>
</blockquote>

python csv pandas series