I have dataframes of same shape but different index datatypes. i want to create a new datatframe from the combined columns
Below is the dataframes
df1
totals | |
---|---|
2014_Q1 | 0 |
2014_Q2 | 0 |
2014_Q3 | 0 |
2014_Q4 | 0 |
2015_Q1 | 0 |
2015_Q2 | 0 |
2015_Q3 | 0 |
2015_Q4 | 0 |
2016_Q1 | 0 |
2016_Q2 | 0 |
2016_Q3 | 0 |
2016_Q4 | 0 |
2017_Q1 | 0 |
2017_Q2 | 0 |
2017_Q3 | 0 |
2017_Q4 | 0 |
2018_Q1 | 0 |
2018_Q2 | 0 |
2018_Q3 | 0 |
2018_Q4 | 0 |
2019_Q1 | 0 |
2019_Q2 | 0 |
2019_Q3 | 0 |
2019_Q4 | 0 |
df2
0 | 1 | |
---|---|---|
0 | 2014 | Q1 |
1 | 2014 | Q2 |
2 | 2014 | Q3 |
3 | 2014 | Q4 |
4 | 2015 | Q1 |
5 | 2015 | Q2 |
6 | 2015 | Q3 |
7 | 2015 | Q4 |
8 | 2016 | Q1 |
9 | 2016 | Q2 |
10 | 2016 | Q3 |
11 | 2016 | Q4 |
12 | 2017 | Q1 |
13 | 2017 | Q2 |
14 | 2017 | Q3 |
15 | 2017 | Q4 |
16 | 2018 | Q1 |
17 | 2018 | Q2 |
18 | 2018 | Q3 |
19 | 2018 | Q4 |
20 | 2019 | Q1 |
21 | 2019 | Q2 |
22 | 2019 | Q3 |
23 | 2019 | Q4 |
I want something like this
Tried this code
pd.concat([df,dframe], axis=1, ignore_index=True)
gives me a long dataframe with NaN’s and push the second dataframe down