Problem with concatenating two dataframes
MRAB
python at mrabarnett.plus.com
Sat Nov 6 16:37:51 EDT 2021
On 2021-11-06 20:12, Mahmood Naderan wrote:
> >Try this instead:
> >
> >
> > dict[name] = pd.concat([dict[name], values])
>
>
> OK. That fixed the problem, however, I see that they are concatenated vertically. How can I change that to horizontal? The printed dictionary in the end looks like
>
>
> {'dummy': Value
> M1 0
> M2 0
> M3 0, 'K1': Value
> 0 10
> 1 5
> 2 10
> 6 2
> 7 2
> 8 2, 'K2': Value
> 3 20
> 4 10
> 5 15}
>
>
>
> For K1, there should be three rows and two columns labeled as Value.
>
The second argument of pd.concat is 'axis', which defaults to 0. Try
using 1 instead of 0.
More information about the Python-list
mailing list