I have two dataframes-
cols = ['A','B']
data = [[-1,2],[0,2],[5,1]]
data = np.asarray(data)
indices = np.arange(0,len(data))
df = pd.DataFrame(data, index=indices, columns=cols)
cols = ['A','B']
data2 = [[-13,2],[-1,2],[0,4],[2,1],[5,0]]
data2 = np.asarray(data2)
indices = np.arange(0,len(data2))
df2 = pd.DataFrame(data2, index=indices, columns=cols)
Now I want to create a new dataframe which has for the same A the maximum of B from either dataframe.
Therefore, the output would be-
A B
0 -13 2
1 -1 2
2 0 4
3 2 1
4 5 1
df = pd.DataFrame([[-1,2],[0,2],[5,1]], columns=['A','B']). You don't need to castdata = np.asarray(data), and you don't need to generate and pass in the indices, it defaults to range-indices like you want. Makes your example much clearer.