Skip to content

Use applymap instead of np.vectorize

Compare
Choose a tag to compare
@bra-fsn bra-fsn released this 09 Sep 09:47
· 8 commits to master since this release
Replace numpy.vectorize, which is faster, but has its limitations:

      1. it supports maximum of 32 columns (ValueError: Cannot construct 
a
         ufunc with more than 32 operands)
      2. it samples the first row of each columns for the type and if 
that's
         an np.nan, it will force float for the whole column.
      3. #2 can be turned off by manually giving the otypes, but it 
might
         fail on some types, like datetime:
            TypeError: Cannot interpret 'datetime64[ns, UTC]' as a data 
type