7 examples of 'pandas merge asof' in Python

Every line of 'pandas merge asof' 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
332def merge_datasets(self, other):
333 """
334 This operation combines two dataframes into one new DataFrame.
335 If the operation is combining two SpatialDataFrames, the
336 geometry_type must match.
337 """
338 if isinstance(other, SpatialDataFrame) and \
339 other.geometry_type == self.geometry_type:
340 return pd.concat(objs=[self, other], axis=0)
341 elif isinstance(other, DataFrame):
342 return pd.concat(objs=[self, other], axis=0)
343 elif isinstance(other, Series):
344 self['merged_datasets'] = other
345 elif isinstance(other, SpatialDataFrame) and \
346 other.geometry_type != self.geometry_type:
347 raise ValueError("Spatial DataFrames must have the same geometry type.")
348 else:
349 raise ValueError("Merge datasets cannot merge types %s" % type(other))
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

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
813def merge(old_cols, new_cols):
814 return old_cols + new_cols
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
6def default_merger(x, y):
7 import pandas as pd
8 return pd.concat([x, y])
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()
474def full_merge_of_existing_series(old_series, new_series):
475 """
476 Merges old data with new data.
477 Any Nan in the existing data will be replaced (be careful!)
478
479 :param old_data: pd.Series
480 :param new_data: pd.Series
481
482 :returns: pd.Series
483 """
484 if len(old_series)==0:
485 return new_series
486 if len(new_series)==0:
487 return old_series
488
489 joint_data = pd.concat([old_series, new_series], axis=1)
490 joint_data.columns = ['original', 'new']
491
492 # fill to the left
493 joint_data_filled_across = joint_data.bfill(1)
494 merged_data = joint_data_filled_across['original']
495
496 return merged_data

Related snippets