I have the following dataframe (from a large csv file using pd.read_csv):
sal_vcf_to_df = pd.read_csv(sal_filepath, delimiter='\t', header = 0, index_col = False,
low_memory=False, usecols=['listA', 'Amino_Acid_Change', 'Gene_Name'])
sal_df_wo_na = sal_vcf_to_df.dropna(axis = 0, how = 'any')
sal_df_wo_na['listA'] = sal_df_wo_na['listA'].apply(lambda x : ast.literal_eval(x))
sal_df_wo_na['listA'] = sal_df_wo_na['listA'].apply(lambda x: list(map(float, x)))
The dataframe I got:
listA Amino_Acid_Change Gene_Name
0 "['133', '115', '3', '1']" Q637K ATM
1 "['114', '115', '2', '3']" I111 PIK3R1
2 "['51', '59', '1', '1']" T2491 KMT2C
I'd like to convert the 'listA' column to list of floats. So far I've tried to do it in several steps:
sal_df_wo_na['listA'] = sal_df_wo_na['listA'].apply(lambda x : ast.literal_eval(x))
then:
sal_df_wo_na['DP4_freeBayes'] = sal_df_wo_na['DP4_freeBayes'].apply(lambda x: list(map(float, x)))
But I got the follwing warning after the first step:
SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
Does anyone know how to fix the warning or have a better solution?