Code Sample, a copy-pastable example if possible
import pandas as pd
import numpy as np
arr = np.array([[1,2,3],[4,5,6]])
df = pd.DataFrame(arr)
Problem description
the expected output is arr[0][1] equals df[0][1],but the real thing is that two elems aren't equal in value.I have seen the source code,a code line as following
#other code
value = value.T
/#other code
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: zh_CN.UTF-8
LOCALE: None.None
pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 29.0.1
Cython: 0.24
numpy: 1.12.1
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.1.2
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: 2.6.1
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None
**Comment From: jreback**
In [19]: df
Out[19]:
0 1 2
0 1 2 3
1 4 5 6
In [20]: arr
Out[20]:
array([[1, 2, 3],
[4, 5, 6]])
df[0] selects a *column* of a DataFrame. This is by far a more common operation, whereas ``arr[0]`` is a row-operation.
you can use ``df.loc[0]`` to achieve a row operation if you'd like.
pandas has multiple ways of indexing (via positions or labels) and operators for those. the docs are pretty [complete](http://pandas.pydata.org/pandas-docs/stable/indexing.html)