I lose my values in the columns
<p>HI~ I wanna ask about my problem
I've organized my data using pandas. and I fill my procedure out like below</p>

<pre><code>import pandas as pd
import numpy as np
df1 = pd.read_table(r'E:\ë¹ë°ì´í° ìº í¼ì¤\ê³¨ëª©ìê¶ íë¡íì¼ë§ - ìì¸ ì´ë¦°ë°ì´í° ê´ì¥ 3.ì´ê¸°-16ë5ìë¶1\17.ìê¶-ì¶ì ë§¤ì¶\201301-201605\tbsm_trdar_selng.txt\tbsm_trdar_selng_utf8.txt' , sep='|' ,header=None
,dtype = { '0' : pd.np.int})

df1 = df1.replace('201301', int(201301))

df2 = df1[[0 ,1, 2, 3 ,4, 11,12 ,82 ]]

df2_rename = df2.columns = ['STDR_YM_CD', 'TRDAR_CD', 'TRDAR_CD_NM', 'SVC_INDUTY_CD', 'SVC_INDUTY_CD_NM', 'THSMON_SELNG_AMT', 'THSMON_SELNG_CO', 'STOR_CO'  ]

print(df2.head(40)) 

df3_groupby = df2.groupby(['STDR_YM_CD', 'TRDAR_CD' ])
df4_agg = df3_groupby.agg(np.sum)

print(df4_agg.head(30))
</code></pre>

<p>When I print df2 I can see the 11947 and 11948 values in my TRDAR_CD column. like below picture</p>

<p><a href="http://i.stack.imgur.com/OlrK9.png" rel="nofollow">enter image description here</a></p>

<p>after that, I used groupby function and I lose my 11948 values in my TRDAR_CD column. You can see this situation in below picture</p>

<p><a href="http://i.stack.imgur.com/EshYF.png" rel="nofollow">enter image description here</a></p>

<p>probably, this problem from the warning message?? warning message is 'sys:1: DtypeWarning: Columns (0) have mixed types. Specify dtype option on import or set low_memory=False.' </p>

<p>help me plz</p>

<p>print(df2.info()) is</p>

<p>
RangeIndex: 1089023 entries, 0 to 1089022</p>

<p>Data columns (total 8 columns):</p>

<p>STDR_YM_CD          1089023 non-null object</p>

<p>TRDAR_CD            1089023 non-null int64</p>

<p>TRDAR_CD_NM         1085428 non-null object</p>

<p>SVC_INDUTY_CD       1089023 non-null object</p>

<p>SVC_INDUTY_CD_NM    1089023 non-null object</p>

<p>THSMON_SELNG_AMT    1089023 non-null int64</p>

<p>THSMON_SELNG_CO     1089023 non-null int64</p>

<p>STOR_CO             1089023 non-null int64</p>

<p>dtypes: int64(4), object(4)</p>

<p>memory usage: 66.5+ MB</p>

<p>None</p>

<p><a href="http://pandas.pydata.org/pandas-docs/stable/advanced.html#creating-a-multiindex-hierarchical-index-object" rel="nofollow"><code>MultiIndex</code></a> is called first and second columns and if first level has duplicates by default it 'sparsified' the higher levels of the indexes to make the console output a bit easier on the eyes.</p>

<p>You can show data in first level of <code>MultiIndex</code> by setting <a href="http://pandas.pydata.org/pandas-docs/stable/options.html#available-options" rel="nofollow"><code>display.multi_sparse</code></a> to <code>False</code>.</p>

<p>Sample:</p>

<pre><code>df = pd.DataFrame({'A':[1,1,3],
                   'B':[4,5,6],
                   'C':[7,8,9]})

df.set_index(['A','B'], inplace=True)

print (df)
     C
A B   
1 4  7
  5  8
3 6  9

#temporary set multi_sparse to False
#http://pandas.pydata.org/pandas-docs/stable/options.html#getting-and-setting-options
with pd.option_context('display.multi_sparse', False):
    print (df)
     C
A B   
1 4  7
1 5  8
3 6  9
</code></pre>

<p>EDIT by edit of question:</p>

<p>I think problem is type of value <code>11948</code> is <code>string</code>, so it is omited.</p>

<p>EDIT1 by file:</p>

<p>You can simplify your solution by add parameter <code>usecols</code> in <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow"><code>read_csv</code></a> and then aggregating by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.core.groupby.GroupBy.sum.html" rel="nofollow"><code>GroupBy.sum</code></a>:</p>

<pre><code>import pandas as pd
import numpy as np

df2 = pd.read_table(r'tbsm_trdar_selng_utf8.txt' , 
                    sep='|' ,
                    header=None ,
                    usecols=[0 ,1, 2, 3 ,4, 11,12 ,82],
                    names=['STDR_YM_CD', 'TRDAR_CD', 'TRDAR_CD_NM', 'SVC_INDUTY_CD', 'SVC_INDUTY_CD_NM', 'THSMON_SELNG_AMT', 'THSMON_SELNG_CO', 'STOR_CO'],
                    dtype = { '0' : int})


df4_agg = df2.groupby(['STDR_YM_CD', 'TRDAR_CD' ]).sum()
print(df4_agg.head(10))
                     THSMON_SELNG_AMT  THSMON_SELNG_CO  STOR_CO
STDR_YM_CD TRDAR_CD                                            
201301     11947           1966588856            74798       73
           11948           3404215104            89064      116
           11949           1078973946            42005       45
           11950           1759827974            93245       71
           11953            779024380            21042       84
           11954           2367130386            94033      128
           11956            511840921            23340       33
           11957            329738651            15531       50
           11958           1255880439            42774      118
           11962           1837895919            66692       68
</code></pre>

python pandas