Category : concatenation

List-1 lst1 = [{‘key’: ‘data_collected.service_data’}, {‘key’: ‘gdpr.gdpr_compliance’}, {‘key’: ‘disclosure_of_information.purpose_of_disclosure’}, {‘key’: ‘opt_out.choice_of_opt_out’}] List-2 lst2 = [{‘key’: ‘child_data_protection.parent_guardian_consent’}, {‘key’: ‘ccpa.ccpa_compliance’}, {‘key’: ‘disclosure_of_information.purpose_of_disclosure’}, {‘key’: ‘opt_out.choice_of_opt_out’}] **when i run below code i am not getting proper output ** res = [] for x in lst1: for y in lst2: if x["key"] == y["key"]: if x not in res and ..

Read more

i have a pandas dataframe with a distinct code identifier as detailed below: df1 = pd.DataFrame([[‘a’, 1], [‘b’, 2],[‘c’, 3],[‘d’, 4],[‘e’, 5],[‘f’, 5]], columns=[‘code’, ‘value1’]) with a second dataframe with the following df2 = pd.DataFrame([[‘a’, 11], [‘b’, 12],[‘c’, 13],[‘d’, 14],[‘e’, 15],[‘f’, 16],[‘g’, 17], [‘h’, 2],[‘i’, 3],[‘j’, 4],[‘k’, 5],[‘l’, 5]], columns=[‘code’, ‘value2’]) i would like to ..

Read more

I am struggling to get this to work. I am masking out the NaN’s then concatenating the two series. Is it not possible to concatenation using + in this way? If not what is the best way? row_mask = df[df[win_end].notnull()] df.loc[row_mask, df[‘window_full’]] = df.loc[row_mask, win_start]+’ – ‘+df.loc[row_mask, win_end] print(df[‘window_start’, ‘window_end’, ‘window_full’]) input win_start win_end 2021-12-16 ..

Read more

I have an excel file with over one hundred sheets. Each sheet has the same columns with information. I have concatenated all the sheets in one single file. Script single_file = pd.concat(pd.read_excel(‘multiple_sheets.xlsx’,sheet_name=None),ignore_index=True) single_file.to_csv(‘single_file.csv’) The script works fine. The thing is I would like to add a column that identifies each row of information with the ..

Read more

my code is concatenating two matrices by using def concat_two_matrices(one, two): results = [] for ind in range(len(two)): a = two[ind] indexes = np.argsort(-a[:, 5]) sorted_a = a[indexes, :] final_two = sorted_a[:20] results.append(np.append(one[ind], final_two.flatten())) return results this line final_two = sorted_a[:20] to get only 20 to avoid null arrays .. but if I wrote those ..

Read more