Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chrisaycock opened this issue Sep 19, 2016 · 4 comments · Fixed by #14531
Closed

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

chrisaycock opened this issue Sep 19, 2016 · 4 comments · Fixed by #14531
Labels
API Design Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@chrisaycock
Copy link
Contributor

chrisaycock commented Sep 19, 2016

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')
@jreback
Copy link
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.

@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode API Design labels Sep 19, 2016
@chrisaycock
Copy link
Contributor Author

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.

@jreback
Copy link
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 jreback added this to the Next Major Release milestone Sep 19, 2016
@chrisaycock
Copy link
Contributor Author

@jreback Done.

@jreback jreback modified the milestones: 0.19.2, Next Major Release Nov 22, 2016
jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this issue Dec 24, 2016
yarikoptic added a commit to neurodebian/pandas that referenced this issue Jan 3, 2017
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) (pandas-dev#14957)
  flake8 fix import
  Remove test - from 0.20.0 PR slipped in
  PERF: fix getitem unique_check / initialization issue
  cache and remove boxing (pandas-dev#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 (pandas-dev#13936)
  [Backport pandas-dev#14886] BUG: regression in DataFrame.combine_first with integer columns (GH14687) (pandas-dev#14886)
  Fixed KDE Plot to drop the missing values (pandas-dev#14820)
  ENH: merge_asof() has left_index/right_index and left_by/right_by (pandas-dev#14253) (pandas-dev#14531)
  TST: correct url for test file on s3 (xref pandas-dev#14587)
  ...
yarikoptic added a commit to neurodebian/pandas that referenced this issue Jan 3, 2017
* 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) (pandas-dev#14957)
  flake8 fix import
  Remove test - from 0.20.0 PR slipped in
  PERF: fix getitem unique_check / initialization issue
  cache and remove boxing (pandas-dev#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 (pandas-dev#13936)
  [Backport pandas-dev#14886] BUG: regression in DataFrame.combine_first with integer columns (GH14687) (pandas-dev#14886)
  Fixed KDE Plot to drop the missing values (pandas-dev#14820)
  ENH: merge_asof() has left_index/right_index and left_by/right_by (pandas-dev#14253) (pandas-dev#14531)
  TST: correct url for test file on s3 (xref pandas-dev#14587)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
2 participants