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

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
@chrisaycock
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

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Sep 19, 2016

Contributor

@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

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.

@chrisaycock

This comment has been minimized.

Show comment
Hide comment
@chrisaycock

chrisaycock Sep 19, 2016

Contributor

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

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.

@jreback

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Sep 19, 2016

Contributor

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

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

@jreback jreback added the Enhancement label Sep 19, 2016

@chrisaycock

This comment has been minimized.

Show comment
Hide comment
@chrisaycock

chrisaycock Sep 19, 2016

Contributor

@jreback Done.

Contributor

chrisaycock commented Sep 19, 2016

@jreback Done.

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

jorisvandenbossche added 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

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)
  ...

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

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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment