5 examples of 'combine two dataframes pandas' in Python

Every line of 'combine two dataframes pandas' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
29def _concat(df, type):
30 if df is None:
31 df = pd.DataFrame(_object_blocks[type])
32 else:
33 _df = pd.DataFrame(_object_blocks[type])
34 df = pd.concat([df, _df], sort=True)
35 return df
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

142def append_data(df1, df2):
143 '''
144 Append df2 to df1
145 '''
146 df = pd.concat((df1, df2))
147 return df.groupby(df.index).first()
24def _merge_dataframes(self, dataset_readers_list):
25
26 final_df = None
27 all_dfs = []
28 keys = []
29
30 for dataset, readers in dataset_readers_list:
31 dataset_df = readers[0]
32 for df in readers[1:]:
33 if df is None:
34 continue
35 dataset_df = dataset_df.add(df, fill_value=0.)
36
37 all_dfs.append(dataset_df)
38 keys.append(dataset)
39
40 final_df = pd.concat(all_dfs, keys=keys, names=['dataset'], sort=True)
41
42 return final_df.reset_index()
184def combine(self, obsra, inplace=True):
185 """
186 concatenates a new obsra onto the end of the current one.
187 """
188 newobsra = pd.concat([self.obsra, obsra])
189 if inplace: self.obsra = newobsra
190 return newobsra
84def feature_combiner(df):
85 combs = list(combinations(df.columns, 2))
86 for i, j in combs:
87 column_name = "%s-%s" % (i, j)
88 df[column_name] = df[i] - df[j]
89 return df

Related snippets