superset-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-superset] betodealmeida commented on issue #8253: Fix array casting
Date Wed, 18 Sep 2019 21:30:52 GMT
betodealmeida commented on issue #8253: Fix array casting
URL: https://github.com/apache/incubator-superset/pull/8253#issuecomment-532874901
 
 
   > what are the cases where they would not be the same type? is that suggestive of a
bigger issue?
   > 
   > otherwise, LGTM
   
   @DiggidyDave, we're casting the results from the DB — a list of tuples — into a Numpy
array so we can address each column efficiently:
   
   ```python
   >>> data = [("a", 1), ("b", 10)]
   >>> np.array(data)
   array([['a', '1'],
          ['b', '10']], dtype='<U2')
   >>> np.array(data)[:,0]  # first column
   array(['a', 'b'], dtype='<U2')
   >>> np.array(data)[:,1]  # second column
   array(['1', '10'], dtype='<U2')
   ```
   
   Note that the numbers were cast to unicode, since that's the common type between int and
unicode.
   
   If we use "object", though:
   
   ```python
   >>> np.array(data, dtype='object')
   array([['a', 1],
          ['b', 10]], dtype=object)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Mime
View raw message