Relative Content

Tag Archive for pythonpandasnumpy

How to set max row height in pandas

One column in my Pandas dataframe is too long. How can I set max row height (not number of rows in a dataframe) in pandas so that I can truncate the cells with too much content and have a balanced view of all columns?

Pandas fillna(‘value’) followed by df.replace(‘value’,np.nan) not working

For some reason df.replace() is not working for me. I want to fill nan values with a dummy value, pivot, then turn the dummy values back into nans using replace, but replace is not working. On further investigation it seems that the ‘yy’ value is not being recognised as the same as the fillna value so the function cant find anything to replace. e.g.

TypeError: Cannot convert numpy.ndarray to numpy.ndarray

I’m not sure why but after getting a new install of windows and a new pycharm install and trying to run some previously functional code I am now getting the above error with the code below. Is it a setup issue or has something changed that now makes this code not function? Error happens on the last line. The error doesn’t make sense to me as there should be no conversion required for ndarray to ndarray.