Add left_by/right_by and left_index/right_index to merge_asof() #14253

Closed
chrisaycock opened this Issue Sep 19, 2016 · 4 comments

Comments

Projects
None yet
2 participants
Contributor

chrisaycock commented Sep 19, 2016 edited

The current merge_asof() has only one parameter for by, assuming that both DataFrames have the same column name. It does have left_on and right_on, so perhaps something similar for by would be helpful.

Also, there is no left_index or right_index parameter in merge_asof(). Adding these might be helpful too.

For example:

pd.merge_asof(df1, df2,
              left_index=True, right_on='timestamp',
              left_by='Ticker', right_by='ticker')
Contributor

jreback commented Sep 19, 2016

@chrisaycock can you show an example where they are meaningful?

I did have them initially, but I couldn't come up with a good use case. In that the merge-asof is quite restricted in what you are doing with it and the API area pretty much covers it.

Contributor

chrisaycock commented Sep 19, 2016

The example I'm working through now is that my left table is indexed by timestamp and has a column called 'Ticker', whereas my right table has columns called 'timestamp' and 'ticker'. These are passed in, so I don't have control over what I get. I have to reshape the tables temporarily before calling merge_asof(), and then I have to undo the reshaping in the returned result.

Contributor

jreback commented Sep 19, 2016

@chrisaycock ahh I c. ok, can you update the topsection with an example of using that API then?

jreback added this to the Next Major Release milestone Sep 19, 2016

jreback added the Enhancement label Sep 19, 2016

Contributor

chrisaycock commented Sep 19, 2016

@jreback Done.

@jreback jreback modified the milestone: 0.19.2, Next Major Release Nov 22, 2016

@jorisvandenbossche jorisvandenbossche added a commit to jorisvandenbossche/pandas that referenced this issue Dec 24, 2016

@chrisaycock @jorisvandenbossche chrisaycock + jorisvandenbossche ENH: merge_asof() has left_index/right_index and left_by/right_by (#1…
…4253) (#14531)

(cherry picked from commit 84cad61)
9a6a78f

@yarikoptic yarikoptic added a commit to neurodebian/pandas that referenced this issue Jan 3, 2017

@yarikoptic yarikoptic Merge tag 'v0.19.2' into releases
Version 0.19.2

* tag 'v0.19.2': (78 commits)
  RLS: v0.19.2
  DOC: update release notes for 0.19.2
  TST: skip gbq upload test as flakey
  DOC: clean-up v0.19.2 whatsnew
  DOC: update Pandas Cheat Sheet (GH13202)
  DOC: Pandas Cheat Sheet
  TST: matplotlib 2.0 fix in log limits for barplot (GH14808) (#14957)
  flake8 fix import
  Remove test - from 0.20.0 PR slipped in
  PERF: fix getitem unique_check / initialization issue
  cache and remove boxing (#14931)
  CLN: Resubmit of GH14700.  Fixes GH14554.  Errors other than Indexing…
  Clean up construction of Series with dictionary and datetime index
  BUG: .fillna() for datetime64 with tz is passing thru floats
  BUG: Patch read_csv NA values behaviour
  ENH: merge_asof() has type specializations and can take multiple 'by' parameters (#13936)
  [Backport #14886] BUG: regression in DataFrame.combine_first with integer columns (GH14687) (#14886)
  Fixed KDE Plot to drop the missing values (#14820)
  ENH: merge_asof() has left_index/right_index and left_by/right_by (#14253) (#14531)
  TST: correct url for test file on s3 (xref #14587)
  ...
5f6a820

@yarikoptic yarikoptic added a commit to neurodebian/pandas that referenced this issue Jan 3, 2017

@yarikoptic yarikoptic Merge branch 'releases' into debian
* releases: (78 commits)
  RLS: v0.19.2
  DOC: update release notes for 0.19.2
  TST: skip gbq upload test as flakey
  DOC: clean-up v0.19.2 whatsnew
  DOC: update Pandas Cheat Sheet (GH13202)
  DOC: Pandas Cheat Sheet
  TST: matplotlib 2.0 fix in log limits for barplot (GH14808) (#14957)
  flake8 fix import
  Remove test - from 0.20.0 PR slipped in
  PERF: fix getitem unique_check / initialization issue
  cache and remove boxing (#14931)
  CLN: Resubmit of GH14700.  Fixes GH14554.  Errors other than Indexing…
  Clean up construction of Series with dictionary and datetime index
  BUG: .fillna() for datetime64 with tz is passing thru floats
  BUG: Patch read_csv NA values behaviour
  ENH: merge_asof() has type specializations and can take multiple 'by' parameters (#13936)
  [Backport #14886] BUG: regression in DataFrame.combine_first with integer columns (GH14687) (#14886)
  Fixed KDE Plot to drop the missing values (#14820)
  ENH: merge_asof() has left_index/right_index and left_by/right_by (#14253) (#14531)
  TST: correct url for test file on s3 (xref #14587)
  ...
f3a4da0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment