I have a DataFrame d1 with strings and missing values, such as
d1 = pd.DataFrame([["A", "B", "C"],
["D", np.nan, "F"],
["G", "H", "I"],],
columns=[1, 2, 3])
whose columns I would like to aggregate in single-row DataFrame d2:
Folllowing suggestions in a previous post, tried the following code:
d2 = d1.agg(''.join).to_frame().T
Still, as one of the values in d1 was missing (and, thus, a float), I got the following error:
TypeError: sequence item 1: expected str instance, float found
Would you know how to change missing values in DataFrames to another data type such as string?