如何在python的pandas模块中获得与Data.Frame相同的data.frame?
How to get the same data.frame with Data.Frame in pandas module of python?
在R中,我们可以得到两个data.frame,比如x和y。
> x=data.frame(matrix(1:12,nrow=2,byrow=TRUE))
> y=data.frame(matrix(1:12,nrow=2,byrow=FALSE))
> x
X1 X2 X3 X4 X5 X6
1 1 2 3 4 5 6
2 7 8 9 10 11 12
> y
X1 X2 X3 X4 X5 X6
1 1 3 5 7 9 11
2 2 4 6 8 10 12
>
How to get the same data.frame with Data.Frame in pandas module of python, to get x and y with Data.Frame in pandas module of python Python?
>>> import numpy as np
>>> import pandas as pd
>>> x = pd.DataFrame(np.arange(1,13).reshape(2,-1))
>>> y = pd.DataFrame(np.arange(1,13).reshape(-1,2).T)
>>> x
0 1 2 3 4 5
0 1 2 3 4 5 6
1 7 8 9 10 11 12
>>> y
0 1 2 3 4 5
0 1 3 5 7 9 11
1 2 4 6 8 10 12
在R中,我们可以得到两个data.frame,比如x和y。
> x=data.frame(matrix(1:12,nrow=2,byrow=TRUE))
> y=data.frame(matrix(1:12,nrow=2,byrow=FALSE))
> x
X1 X2 X3 X4 X5 X6
1 1 2 3 4 5 6
2 7 8 9 10 11 12
> y
X1 X2 X3 X4 X5 X6
1 1 3 5 7 9 11
2 2 4 6 8 10 12
>
How to get the same data.frame with Data.Frame in pandas module of python, to get x and y with Data.Frame in pandas module of python Python?
>>> import numpy as np
>>> import pandas as pd
>>> x = pd.DataFrame(np.arange(1,13).reshape(2,-1))
>>> y = pd.DataFrame(np.arange(1,13).reshape(-1,2).T)
>>> x
0 1 2 3 4 5
0 1 2 3 4 5 6
1 7 8 9 10 11 12
>>> y
0 1 2 3 4 5
0 1 3 5 7 9 11
1 2 4 6 8 10 12