Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [1]: from astropy.io import fits
- In [2]: import pandas as pd
- In [3]: d = fits.getdata('pandas.fit')
- In [4]: d
- Out[4]:
- FITS_rec([(293.672708, 48.155611), (219.2110132, 33.303077000000002),
- (92.133392000000001, 14.653280000000001),
- (351.31415700000002, 15.950782), (109.3717, 22.214390000000002),
- (109.35231, 30.833805000000002),
- (121.80719000000001, 4.4392250000000004),
- (135.4007, 30.848746999999999), (102.52856, 38.827131999999999),
- (33.579945000000002, 44.581505)],
- dtype=[('ra', '>f8'), ('de', '>f8')])
- In [5]: np.array(d)
- Out[5]:
- array([(293.672708, 48.155611), (219.2110132, 33.303077),
- (92.133392, 14.65328), (351.314157, 15.950782),
- (109.3717, 22.21439), (109.35231, 30.833805), (121.80719, 4.439225),
- (135.4007, 30.848747), (102.52856, 38.827132),
- (33.579945, 44.581505)],
- dtype=[('ra', '>f8'), ('de', '>f8')])
- In [6]: df = pd.DataFrame(np.array(d))
- In [7]: df
- Out[7]:
- ra de
- 0 293.672708 48.155611
- 1 219.211013 33.303077
- 2 92.133392 14.653280
- 3 351.314157 15.950782
- 4 109.371700 22.214390
- 5 109.352310 30.833805
- 6 121.807190 4.439225
- 7 135.400700 30.848747
- 8 102.528560 38.827132
- 9 33.579945 44.581505
- In [8]: df[df['ra'] > 200]
- ---------------------------------------------------------------------------
- ValueError Traceback (most recent call last)
- <ipython-input-8-977482d317cf> in <module>()
- ----> 1 df[df['ra'] > 200]
- /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/frame.pyc in __getitem__(self, key)
- 1772 if isinstance(key, (Series, np.ndarray, Index, list)):
- 1773 # either boolean or fancy integer index
- -> 1774 return self._getitem_array(key)
- 1775 elif isinstance(key, DataFrame):
- 1776 return self._getitem_frame(key)
- /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/frame.pyc in _getitem_array(self, key)
- 1814 key = _check_bool_indexer(self.index, key)
- 1815 indexer = key.nonzero()[0]
- -> 1816 return self.take(indexer, axis=0, convert=False)
- 1817 else:
- 1818 indexer = self.ix._convert_to_indexer(key, axis=1)
- /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/generic.pyc in take(self, indices, axis, convert, is_copy)
- 1320 new_data = self._data.take(indices,
- 1321 axis=self._get_block_manager_axis(axis),
- -> 1322 convert=True, verify=True)
- 1323 result = self._constructor(new_data).__finalize__(self)
- 1324
- /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/internals.pyc in take(self, indexer, axis, verify, convert)
- 3311 new_labels = self.axes[axis].take(indexer)
- 3312 return self.reindex_indexer(new_axis=new_labels, indexer=indexer,
- -> 3313 axis=axis, allow_dups=True)
- 3314
- 3315 def merge(self, other, lsuffix='', rsuffix=''):
- /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/internals.pyc in reindex_indexer(self, new_axis, indexer, axis, fill_value, allow_dups, copy)
- 3200 fill_tuple=(fill_value if fill_value is not None else
- 3201 blk.fill_value,))
- -> 3202 for blk in self.blocks]
- 3203
- 3204 new_axes = list(self.axes)
- /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/internals.pyc in take_nd(self, indexer, axis, new_mgr_locs, fill_tuple)
- 860 fill_value = fill_tuple[0]
- 861 new_values = com.take_nd(self.get_values(), indexer, axis=axis,
- --> 862 allow_fill=True, fill_value=fill_value)
- 863
- 864 if new_mgr_locs is None:
- /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/common.pyc in take_nd(arr, indexer, axis, out, fill_value, mask_info, allow_fill)
- 817
- 818 indexer = _ensure_int64(indexer)
- --> 819 func(arr, indexer, out, fill_value)
- 820
- 821 if flip_order:
- pandas/src/generated.pyx in pandas.algos.take_2d_axis1_float64_float64 (pandas/algos.c:95513)()
- ValueError: Big-endian buffer not supported on little-endian compiler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement