Skip to content
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

BUG: Datetime64Formatter not respecting formatter #13567

Closed
wants to merge 1 commit into from
Closed

BUG: Datetime64Formatter not respecting formatter #13567

wants to merge 1 commit into from

Conversation

haleemur
Copy link
Contributor

@haleemur haleemur commented Jul 5, 2016

the Datetime64Formatter class did not accept a formatter argument, so custom formatters passed in through df.to_string or df.to_html were silently ignored.

@haleemur haleemur changed the title fix bug in Datetime64Formatter BUG: Datetime64Formatter not respecting formatter Jul 5, 2016
self.assertEqual(result, ['2016-01', '2016-02', '2016-03'])

def test_format_dataframe_column(self):
months = [datetime(2016,1,1), datetime(2016,2,2), datetime(2016,3,3)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this last test goes with all of the test_to_string* tests.

@jreback jreback added Timeseries Output-Formatting __repr__ of pandas objects, to_string labels Jul 5, 2016
@jreback jreback added this to the 0.18.2 milestone Jul 5, 2016
@@ -4161,6 +4161,21 @@ def test_dates_display(self):
self.assertEqual(result[1].strip(), "NaT")
self.assertEqual(result[4].strip(), "2013-01-01 09:00:00.000000004")

def test_datetime64formatter(self):
x = Series([datetime(2016,1,1), datetime(2016,2,2), datetime(2016,3,3)])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a test where to_html are tested as well

@jorisvandenbossche jorisvandenbossche added the IO HTML read_html, to_html, Styler.apply, Styler.applymap label Jul 5, 2016
@codecov-io
Copy link

codecov-io commented Jul 6, 2016

Current coverage is 84.34%

Merging #13567 into master will increase coverage by 0.03%

@@             master     #13567   diff @@
==========================================
  Files           138        138          
  Lines         51155      51135    -20   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43130      43132     +2   
+ Misses         8025       8003    -22   
  Partials          0          0          

Powered by Codecov. Last updated by 2655dae...3146ded

@jreback
Copy link
Contributor

jreback commented Jul 6, 2016

lgtm.

@@ -528,3 +528,5 @@ Bug Fixes

- Bug in ``Categorical.remove_unused_categories()`` changes ``.codes`` dtype to platform int (:issue:`13261`)
- Bug in ``groupby`` with ``as_index=False`` returns all NaN's when grouping on multiple columns including a categorical one (:issue:`13204`)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note the reason we leave space in the bug fix section is to avoid conflicts (IOW put up higher in a blank space). @jorisvandenbossche you prob want to move on merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the tip, added blank lines before my bugfix entry. hope that helps with the merge.

…output for df.to_string, df.to_html methods

added tests for time of day formatting and df.to_html
added test for formatters kw for df.to_latex

add whatsnew entry

move whatsnew entry higher up
@jorisvandenbossche
Copy link
Member

@haleemur Merged, thanks a lot!

(I moved the whatsnew note to 0.19.0, as master is now targeted for that)

@haleemur haleemur deleted the fix/dt64_outputformat branch July 9, 2016 00:43
nateGeorge pushed a commit to nateGeorge/pandas that referenced this pull request Aug 15, 2016
 - [x] closes pandas-dev#10690   - [x] tests added / passed   - [x] passes ``git
diff upstream/master | flake8 --diff``   - [x] whatsnew entry    the
Datetime64Formatter class did not accept a `formatter` argument, so
custom formatters passed in through `df.to_string` or `df.to_html`
were silently ignored.

Author: Haleemur Ali <haleemur@gmail.com>

This patch had conflicts when merged, resolved by
Committer: Joris Van den Bossche <jorisvandenbossche@gmail.com>

Closes pandas-dev#13567 from haleemur/fix/dt64_outputformat and squashes the following commits:

8d84283 [Haleemur Ali] fix bug in Datetime64Formatter, which affected custom date formatted output for df.to_string, df.to_html methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string Timeseries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

to_html() formatters does not work for objects with 'datetime64[ns]' type
4 participants