Is there any way to prevent pandas from changing the default print format for numpy arrays?
With plain numpy, I get:
>>> numpy.array([123.45, 0.06])
array([ 1.23450000e+02, 6.00000000e-02])
After I import pandas, I get:
>>> numpy.array([123.45, 0.06])
array([ 123.45, 0.06])
Can I stop it from doing this as a configuration setting? I don't want to have to wrap every "import pandas" with a "foo=np.get_printoptions(); import pandas; np.set_printoptions(**foo)", but that's the best I can come up with.
As it is, if I import pandas in one place, I get doctest errors from another.
You should only have to wrap the first import pandas with np.set_printoptions(foo) since python will cache it. See below:
import numpy
>>> numpy.array([123.45, 0.06])
array([ 1.23450000e+02, 6.00000000e-02])
>>> import pandas
>>> numpy.array([123.45, 0.06])
array([ 123.45, 0.06])
>>> numpy.set_printoptions(edgeitems=3,infstr='inf', linewidth=75, nanstr='nan', precision=8, suppress=False, threshold=1000)
>>> numpy.array([123.45, 0.06])
array([ 1.23450000e+02, 6.00000000e-02])
>>> import pandas
>>> numpy.array([123.45, 0.06])
array([ 1.23450000e+02, 6.00000000e-02])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With