@@ -183,9 +183,6 @@ def where(self, key_idx, value, condition="eq"):
183183 NavData with columns where given condition is satisfied
184184 for specified row
185185 """
186- # Add a condition here instead of just comparing to a value.
187- # Do so by adding a parameter for less than inequality, equality and
188- # greater than inequality
189186 new_cols = self .argwhere (key_idx , value , condition )
190187 if new_cols .size == 0 :
191188 return self .remove (cols = list (range (len (self ))))
@@ -242,11 +239,13 @@ def argwhere(self, key_idx, value, condition="eq"):
242239 # Find columns where value can be found and return new NavData
243240 if condition == "eq" :
244241 if not isinstance (value ,str ) and np .isnan (value ):
242+ # check isinstance b/c np.isnan can't handle strings
245243 new_cols = np .argwhere (np .isnan (self .array [row , :]))
246244 else :
247245 new_cols = np .argwhere (self .array [row , :]== value )
248246 elif condition == "neq" :
249247 if not isinstance (value ,str ) and np .isnan (value ):
248+ # check isinstance b/c np.isnan can't handle strings
250249 new_cols = np .argwhere (~ np .isnan (self .array [row , :]))
251250 else :
252251 new_cols = np .argwhere (self .array [row , :]!= value )
@@ -563,7 +562,7 @@ def in_rows(self, rows):
563562
564563 if isinstance (rows ,str ):
565564 rows = [rows ]
566- if type (rows ) in (list , np .ndarray , tuple ):
565+ if isinstance (rows , (list , np .ndarray , tuple ) ):
567566 if isinstance (rows ,np .ndarray ):
568567 rows = np .atleast_1d (rows )
569568 missing_rows = ["'" + row + "'" for row in rows
@@ -716,8 +715,8 @@ def __setitem__(self, key_idx, new_value):
716715 if isinstance (key_idx , str ) and key_idx not in self .map :
717716 #Creating an entire new row
718717 if isinstance (new_value , np .ndarray ) \
719- and (new_value .dtype in (object ,str ) \
720- or np .issubdtype (new_value .dtype ,np .dtype ('U' ))):
718+ and (new_value .dtype in (object ,str ) \
719+ or np .issubdtype (new_value .dtype ,np .dtype ('U' ))):
721720 # Adding string values
722721 new_value = new_value .astype (str )
723722 new_str_vals = len (np .unique (new_value ))* np .ones (np .shape (new_value ),
@@ -759,9 +758,9 @@ def __setitem__(self, key_idx, new_value):
759758 "Cannot assign/return combination of strings and numbers"
760759 if np .all (row_str ):
761760 assert isinstance (new_value , np .ndarray ) \
762- and (new_value .dtype in (object ,str ) \
763- or np .issubdtype (new_value .dtype ,np .dtype ('U' ))), \
764- "String assignment only supported for ndarray of type object"
761+ and (new_value .dtype in (object ,str ) \
762+ or np .issubdtype (new_value .dtype ,np .dtype ('U' ))), \
763+ "String assignment only supported for ndarray of type object"
765764 inv_map = self .inv_map
766765 new_value = np .atleast_2d (new_value )
767766 new_str_vals = np .ones_like (new_value , dtype = self .arr_dtype )
@@ -882,7 +881,7 @@ def _get_set_str_rows(self, rows, new_value):
882881
883882 if isinstance (new_value , np .ndarray ) and (new_value .dtype in (object ,str ) \
884883 or np .issubdtype (new_value .dtype ,np .dtype ('U' ))):
885- if type (new_value .item (0 )) in (int , float ):
884+ if isinstance (new_value .item (0 ), (int , float ) ):
886885 row_str_new = [False ]* len (row_list )
887886 else :
888887 row_str_new = [True ]* len (row_list )
0 commit comments