I have lists of unknown columns in python and I want to split it into rows.How I can do this.
numberArray1 | numberArray10 |numberArray11 | . . .
[32.09561, 32.43092, 32.37599]| [37.015972, 37.015972, 36.889534] | [996.2953, 996.2609, 996.28845]|. . . . to N columns
This all data stores in cells of dataframe
Need to convert the horizontal value in my rows to vertical values corresponding to the respective columns.
Expected output would be.
numberArray1 numberArray10 numberArray11
32.09561 37.015972 996.2953
32.43092 37.015972 996.2609
32.37599 36.889534 996.28845
you can use pandas,
import pandas as pd
df=pd.read_csv("your_csv.csv")
new_df=pd.DataFrame()
for col in df.columns:
new_df[col]=pd.DataFrame({col:pd.Series(df[col][0].str[1:-1].split(','))})
new_df
is your expected dataframe
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments