I\'m trying to set a number of different in a pandas DataFrame all to the same value. I thought I understood boolean indexing for pandas, but I haven\'t found any resources
pandas
uses NaN
to mark invalid or missing data and can be used across types, since your DataFrame
as mixed int and string data types it will not accept the assignment to a single type (other than NaN
) as this would create a mixed type (int and str) in B
through an in-place assignment.
@JohnE method using np.where
creates a new DataFrame
in which the type of column B
is an object not a string as in the initial example.