is this a series or dataframe?
<p>I am quite new to Python, and have some basic questions which I could not find answer till now.</p>

<p>suppose I have the following dataframe named phone.</p>

<pre><code>     current_cellphone  | months of usage |  previous_cellphone
0   |     Motorola       |     11          |    Motorola
1   |     Huawei         |     21          |    Nokia
2   |     Motorola       |     13          |    Motorola
3   |     Nokia          |     2           |    iphone
4   |     Huawei         |     20          |    Huawei
5   |     Motorola       |     15          |    Motorola
6   |     Sony           |     9           |    HTC
</code></pre>

<p>My initiative is to group by current_cellphone, select those which are counted more than once (Motorola and Huawei).</p>

<pre><code>phone['current_cellphone'].value_counts
</code></pre>

<p>The result is </p>

<pre><code>Motorola      |      3
Huawei        |      2
Nokia         |      1
</code></pre>

<p><strong>My 1st question is :</strong> does the code above yield a dataframe or series?</p>

<p><strong>My 2nd question is</strong>: how do I retrieve the first and second column of the above table? </p>

<p>Thank you very much for your helps.. </p>

<p>It's <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.html" rel="nofollow">pandas.Series</a> object. You can find that out using <a href="https://docs.python.org/2/library/functions.html#type" rel="nofollow">type()</a>.</p>

<pre><code>In [157]: phone
Out[157]: 
  current_cellphone  |  months of     usage  |.1  previous_cellphone
0          Motorola  |      11  |  Motorola  NaN                 NaN
1            Huawei  |      21  |     Nokia  NaN                 NaN
2          Motorola  |      13  |  Motorola  NaN                 NaN
3             Nokia  |       2  |    iphone  NaN                 NaN
4            Huawei  |      20  |    Huawei  NaN                 NaN
5          Motorola  |      15  |  Motorola  NaN                 NaN
6              Sony  |       9  |       HTC  NaN                 NaN

In [158]: vc = phone['current_cellphone'].value_counts()

In [159]: vc
Out[159]: 
Motorola    3
Huawei      2
Nokia       1
Sony        1
Name: current_cellphone, dtype: int64

In [160]: type(vc)
Out[160]: pandas.core.series.Series
</code></pre>

<p>To extract the information from the series:</p>

<pre><code>In [169]: vc.values
Out[169]: array([3, 2, 1, 1])

In [170]: vc.keys()
Out[170]: Index([u'Motorola', u'Huawei', u'Nokia', u'Sony'], dtype='object')

In [176]: vc.to_dict()
Out[176]: {'Huawei': 2, 'Motorola': 3, 'Nokia': 1, 'Sony': 1}

In [177]: vc.to_dict().keys()
Out[177]: ['Nokia', 'Huawei', 'Motorola', 'Sony']

In [178]: vc.to_dict().values()
Out[178]: [1, 2, 3, 1]
</code></pre>

<p>Converting to dataframe:</p>

<pre><code>In [180]: pd.DataFrame(vc)
Out[180]: 
          current_cellphone
Motorola                  3
Huawei                    2
Nokia                     1
Sony                      1
</code></pre>

python pandas numpy