import pandas as pd
import numpy as np
df=pd.read_csv('〜〜〜.csv',header=None,names=('name', 'id'))
Specify the column name with names = ~ ~. header = None prevents the first line from being recognized as header.
df=df.replace('A B', 'AB')
df=df.replace('B A', 'BA')
df2 = pd.concat([df, df['name'].str.split(' ', expand=True)], axis=1).drop('name', axis=1)
df=df.loc[:,["Column name","Column name","Column name"]]
df3=pd.concat([df1, df2])
df=df[~df.duplicated()]
df[df["Column name"]=="~~"]
df_list=df.values.tolist()
df_list=np.array(df['Column name'])
Recommended Posts