I'm adding a first row from a dictionary to index 0 to Dataframe.
df = pd.DataFrame({
"names": ["a", "a", "a"],
"org_names": ["a", "a", "a"],
"math" : ["!not_div", "=", "*"],
"values": [1, 2, 3],
"end_result" : ["", 1,2]
})
data = {"interception": 1,
"a": 2,
"b": 3,
"c": 5,
"d": 6
}
df1 = pd.DataFrame([{
"names": list(data.keys())[0],
"org_names": "",
"math" : "",
"values": "",
"end_result" : 1,
}])
new_df = pd.concat([df1, df], axis=0)
output:
names org_names math values end_result
0 interception 1
0 a a !not_div 1
1 a a = 2 1
2 a a * 3 2
Is there a better way to do this? That's not using the concat?