| Download
Jupyter notebook 2017-04-07-142242.ipynb
Project: pyton
Path: 2017-04-07-142242.ipynb
Views: 108Kernel: Python 3 (Ubuntu Linux)
In [1]:
In [2]:
[1 2 3 4 5]
In [3]:
5
5
In [4]:
dtype('int64')
In [5]:
(5,)
In [6]:
[ 1. 2. 3. 4. 5.] float64 (5,)
In [7]:
[ 1. 2. 3. 4. 5.] float16 (5,)
In [8]:
array([1, 2, 3, 4, 5], dtype=int32)
In [9]:
[[ 1. 2.]
[ 3. 4.]
[ 5. 6.]]
In [10]:
len: 3
size: 6
dtype: float64
shape: (3, 2)
In [11]:
[[ 1. 3. 5.]
[ 2. 4. 6.]]
len: 2
size: 6
dtype: float64
shape: (2, 3)
In [12]:
[1 2 3 4 5]
len: 5
size: 5
dtype: int64
shape: (5,)
In [13]:
[[ 1. 2.]
[ 3. 4.]
[ 5. 6.]]
[ 1. 2. 3. 4. 5. 6.]
In [14]:
[[ 1. 2.]
[ 3. 4.]
[ 5. 6.]]
[[ 1.]
[ 2.]
[ 3.]
[ 4.]
[ 5.]
[ 6.]]
In [15]:
[[ 1. 2.]
[ 3. 4.]
[ 5. 6.]]
[[ 1. 2. 3. 4. 5. 6.]]
In [16]:
[[ 1. 2.]
[ 3. 4.]
[ 5. 6.]]
[[ 1. 2. 3. 4. 5. 6.]]
In [17]:
4.0
In [18]:
array([ 3., 4.])
In [19]:
array([ 2., 4., 6.])
In [20]:
6.0
In [21]:
array([ 5., 6.])
In [22]:
array([ 2., 4., 6.])
In [23]:
[ 0.5647215 0.00094002 0.24878213 0.68678843 0.52699816 0.03735719
0.2454302 ]
[ 0.00094002 0.03735719 0.2454302 0.24878213 0.52699816 0.5647215
0.68678843]
In [24]:
[[ 0.64321401 0.65931002 0.21608559]
[ 0.92885038 0.564786 0.39182436]]
[[ 0.21608559 0.64321401 0.65931002]
[ 0.39182436 0.564786 0.92885038]]
In [25]:
[[ 0.16288666 0.11172614 0.35282611]
[ 0.38132885 0.02666066 0.15043217]]
[[ 0.16288666 0.02666066 0.15043217]
[ 0.38132885 0.11172614 0.35282611]]
In [26]:
[[ 0.12819814 0.48234593 0.86324019]
[ 0.45798466 0.12867528 0.55265798]]
[[ 0.12819814 0.48234593 0.86324019]
[ 0.12867528 0.45798466 0.55265798]]
In [27]:
[[ 0.30914498 0.64406892 0.08580514]
[ 0.25394587 0.39194642 0.92343702]]
[[2 0 1]
[0 1 2]]
In [28]:
10.0
In [29]:
[[ 2. 3.]
[ 3. 1.]
[ 1. 2.]]
In [30]:
array([ 5., 4., 3.])
In [31]:
[(1, 2.) (2, 3.)]
[('id', '<i4'), ('val', '<f8')]
In [32]:
(1, 2.)
In [33]:
[1 2] [ 2. 3.]
In [34]:
1
In [35]:
b'\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08@'
In [36]:
b'\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x08@\x00\x00\x00\x00\x00\x00\x08@\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00\x00\x00@'
In [37]:
array([(1, 2.), (2, 3.)],
dtype=[('id', '<i4'), ('val', '<f8')])
In [38]:
[[2.0, 3.0], [3.0, 1.0], [1.0, 2.0]]
In [39]:
[(1, 2.0), (2, 3.0)]
In [40]:
[ 0.63959344 0.72079659 0.86719556 0.24628904 0.15319488 0.05360769
0.97353974]
[ 0.48495132 0.68221772 0.09359279 0.29566355 0.18079382 0.52736749
0.78261675]
[ 1.12454475 1.4030143 0.96078836 0.54195259 0.3339887 0.58097517
1.75615649]
In [41]:
[ 0.64425754 0.98496873 0.76078776 0.14807523 0.05615508 0.28099025
1.5602686 ]
In [42]:
[ 0.79974586 0.8489974 0.93123336 0.49627516 0.39140117 0.23153334
0.98668118]
In [43]:
[ 1.89571 2.0560704 2.38022629 1.27926927 1.16555209 1.0550706
2.64729865]
In [44]:
In [45]:
In [46]:
[(1, 2.) (2, 3.)]
In [47]:
<class 'numpy.ndarray'> [('id', '<i4'), ('val', '<f8')] (2,)
In [48]:
In [49]:
In [50]:
In [51]:
['sepal lenght', 'sepal width', 'petal length', 'petal width', 'class']
In [52]:
In [53]:
<class 'pandas.core.frame.DataFrame'>
sepal lenght | sepal width | petal length | petal width | class | |
---|---|---|---|---|---|
0 | 5.1 | 3.5 | 1.4 | 0.2 | Iris-setosa |
1 | 4.9 | 3.0 | 1.4 | 0.2 | Iris-setosa |
2 | 4.7 | 3.2 | 1.3 | 0.2 | Iris-setosa |
3 | 4.6 | 3.1 | 1.5 | 0.2 | Iris-setosa |
4 | 5.0 | 3.6 | 1.4 | 0.2 | Iris-setosa |
5 | 5.4 | 3.9 | 1.7 | 0.4 | Iris-setosa |
6 | 4.6 | 3.4 | 1.4 | 0.3 | Iris-setosa |
7 | 5.0 | 3.4 | 1.5 | 0.2 | Iris-setosa |
8 | 4.4 | 2.9 | 1.4 | 0.2 | Iris-setosa |
9 | 4.9 | 3.1 | 1.5 | 0.1 | Iris-setosa |
10 | 5.4 | 3.7 | 1.5 | 0.2 | Iris-setosa |
11 | 4.8 | 3.4 | 1.6 | 0.2 | Iris-setosa |
12 | 4.8 | 3.0 | 1.4 | 0.1 | Iris-setosa |
13 | 4.3 | 3.0 | 1.1 | 0.1 | Iris-setosa |
14 | 5.8 | 4.0 | 1.2 | 0.2 | Iris-setosa |
15 | 5.7 | 4.4 | 1.5 | 0.4 | Iris-setosa |
16 | 5.4 | 3.9 | 1.3 | 0.4 | Iris-setosa |
17 | 5.1 | 3.5 | 1.4 | 0.3 | Iris-setosa |
18 | 5.7 | 3.8 | 1.7 | 0.3 | Iris-setosa |
19 | 5.1 | 3.8 | 1.5 | 0.3 | Iris-setosa |
20 | 5.4 | 3.4 | 1.7 | 0.2 | Iris-setosa |
21 | 5.1 | 3.7 | 1.5 | 0.4 | Iris-setosa |
22 | 4.6 | 3.6 | 1.0 | 0.2 | Iris-setosa |
23 | 5.1 | 3.3 | 1.7 | 0.5 | Iris-setosa |
24 | 4.8 | 3.4 | 1.9 | 0.2 | Iris-setosa |
25 | 5.0 | 3.0 | 1.6 | 0.2 | Iris-setosa |
26 | 5.0 | 3.4 | 1.6 | 0.4 | Iris-setosa |
27 | 5.2 | 3.5 | 1.5 | 0.2 | Iris-setosa |
28 | 5.2 | 3.4 | 1.4 | 0.2 | Iris-setosa |
29 | 4.7 | 3.2 | 1.6 | 0.2 | Iris-setosa |
... | ... | ... | ... | ... | ... |
120 | 6.9 | 3.2 | 5.7 | 2.3 | Iris-virginica |
121 | 5.6 | 2.8 | 4.9 | 2.0 | Iris-virginica |
122 | 7.7 | 2.8 | 6.7 | 2.0 | Iris-virginica |
123 | 6.3 | 2.7 | 4.9 | 1.8 | Iris-virginica |
124 | 6.7 | 3.3 | 5.7 | 2.1 | Iris-virginica |
125 | 7.2 | 3.2 | 6.0 | 1.8 | Iris-virginica |
126 | 6.2 | 2.8 | 4.8 | 1.8 | Iris-virginica |
127 | 6.1 | 3.0 | 4.9 | 1.8 | Iris-virginica |
128 | 6.4 | 2.8 | 5.6 | 2.1 | Iris-virginica |
129 | 7.2 | 3.0 | 5.8 | 1.6 | Iris-virginica |
130 | 7.4 | 2.8 | 6.1 | 1.9 | Iris-virginica |
131 | 7.9 | 3.8 | 6.4 | 2.0 | Iris-virginica |
132 | 6.4 | 2.8 | 5.6 | 2.2 | Iris-virginica |
133 | 6.3 | 2.8 | 5.1 | 1.5 | Iris-virginica |
134 | 6.1 | 2.6 | 5.6 | 1.4 | Iris-virginica |
135 | 7.7 | 3.0 | 6.1 | 2.3 | Iris-virginica |
136 | 6.3 | 3.4 | 5.6 | 2.4 | Iris-virginica |
137 | 6.4 | 3.1 | 5.5 | 1.8 | Iris-virginica |
138 | 6.0 | 3.0 | 4.8 | 1.8 | Iris-virginica |
139 | 6.9 | 3.1 | 5.4 | 2.1 | Iris-virginica |
140 | 6.7 | 3.1 | 5.6 | 2.4 | Iris-virginica |
141 | 6.9 | 3.1 | 5.1 | 2.3 | Iris-virginica |
142 | 5.8 | 2.7 | 5.1 | 1.9 | Iris-virginica |
143 | 6.8 | 3.2 | 5.9 | 2.3 | Iris-virginica |
144 | 6.7 | 3.3 | 5.7 | 2.5 | Iris-virginica |
145 | 6.7 | 3.0 | 5.2 | 2.3 | Iris-virginica |
146 | 6.3 | 2.5 | 5.0 | 1.9 | Iris-virginica |
147 | 6.5 | 3.0 | 5.2 | 2.0 | Iris-virginica |
148 | 6.2 | 3.4 | 5.4 | 2.3 | Iris-virginica |
149 | 5.9 | 3.0 | 5.1 | 1.8 | Iris-virginica |
150 rows × 5 columns
In [54]:
RangeIndex(start=0, stop=150, step=1)
In [58]:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/usr/local/lib/python3.4/dist-packages/pandas/indexes/base.py in get_loc(self, key, method, tolerance)
2133 try:
-> 2134 return self._engine.get_loc(key)
2135 except KeyError:
pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4433)()
pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4279)()
pandas/src/hashtable_class_helper.pxi in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:13742)()
pandas/src/hashtable_class_helper.pxi in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:13696)()
KeyError: 'sepal length'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-58-2ca01e06736b> in <module>()
----> 1 col = iris_df ["sepal length"]
2 print(type(col))
3 col
/usr/local/lib/python3.4/dist-packages/pandas/core/frame.py in __getitem__(self, key)
2057 return self._getitem_multilevel(key)
2058 else:
-> 2059 return self._getitem_column(key)
2060
2061 def _getitem_column(self, key):
/usr/local/lib/python3.4/dist-packages/pandas/core/frame.py in _getitem_column(self, key)
2064 # get column
2065 if self.columns.is_unique:
-> 2066 return self._get_item_cache(key)
2067
2068 # duplicate columns & possible reduce dimensionality
/usr/local/lib/python3.4/dist-packages/pandas/core/generic.py in _get_item_cache(self, item)
1384 res = cache.get(item)
1385 if res is None:
-> 1386 values = self._data.get(item)
1387 res = self._box_item_values(item, values)
1388 cache[item] = res
/usr/local/lib/python3.4/dist-packages/pandas/core/internals.py in get(self, item, fastpath)
3541
3542 if not isnull(item):
-> 3543 loc = self.items.get_loc(item)
3544 else:
3545 indexer = np.arange(len(self.items))[isnull(self.items)]
/usr/local/lib/python3.4/dist-packages/pandas/indexes/base.py in get_loc(self, key, method, tolerance)
2134 return self._engine.get_loc(key)
2135 except KeyError:
-> 2136 return self._engine.get_loc(self._maybe_cast_indexer(key))
2137
2138 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4433)()
pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4279)()
pandas/src/hashtable_class_helper.pxi in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:13742)()
pandas/src/hashtable_class_helper.pxi in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:13696)()
KeyError: 'sepal length'
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: