Issue
I have a DataFrame as below:
import pandas as pd
df_testcase = pd.DataFrame(
['16SCSE102014', '15/03/2019', '16SCSE101350', '15/03/2019']
)
0
0 16SCSE102014
1 15/03/2019
2 16SCSE101350
3 15/03/2019
I need to convert it into 2x2 DataFrame like this:
0 1
0 16SCSE102014 15/03/2019
1 16SCSE101350 15/03/2019
Can someone please help?
Solution
You can alter the shape of your data using reshape
after converting the DataFrame df2
to a numpy ndarray with .values
then convert the resulting array back into a DataFrame:
# If res is your (4,1) DataFrame, you can just do
res = df2.values.reshape(2,2)
df = pd.DataFrame(res)
Answered By - Akaisteph7
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.