I need help with this. I want to add the second column in one dataframe to the second column in another dataframe based on index, and then put the result in a third dataframe. Ignore the time column
The Input: Dataframe A
| time | S |
|---|---|
| 2:30 | 5 |
| 2:35 | 9 |
| 2:40 | 300 |
| 2:45 | 200 |
Dataframe B
| time | S |
|---|---|
| 3:00 | 23 |
| 3:05 | 40 |
| 3:10 | 450 |
| 3:15 | 346 |
This is what I was thinking...
import pandas
dfa = pd.read_csv('T.csv')
dfb = pd.read_csv('H.csv')
s = dfa[dfa.columns[1]] + dfb[dfb.columns[1]]
At the moment, I'm getting this error (TypeError: can only concatenate str (not "float") to str)
Note: Please if you think there's another way to approach the problem I'm all ears.
Possible Output:
| time | S |
|---|---|
| 4:30 | 28 |
| 4:35 | 49 |
| 4:40 | 750 |
| 4:45 | 546 |