question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sorting table with `Time` column fails

See original GitHub issue

Trying to sort a table with a time column fails:

from astropy.time import Time
from astropy.table import Table
from astropy.coordinates import EarthLocation
t = Table()
t['a'] = Time([100.0, 200.0], scale='tt', format='mjd',
              location=EarthLocation(-2446354, 4237210, 4077985, unit='m'))
t['b'] = [3, 1]
t.sort('b')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-60-186ab71ceb04> in <module>()
      6               location=EarthLocation(-2446354, 4237210, 4077985, unit='m'))
      7 t['b'] = [3, 1]
----> 8 t.sort('b')

~/conda-main/envs/ipyfits/lib/python3.6/site-packages/astropy/table/table.py in sort(self, keys)
   2475 
   2476         for col in self.columns.values():
-> 2477             col[:] = col.take(indexes, axis=0)
   2478 
   2479         if sort_index is not None:

TypeError: 'Time' object does not support item assignment

(Apologies if all of the issues I’m opening here are known issues or the expected behavior)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
taldcroftcommented, Nov 4, 2018

Yes sorting relies on Time being mutable which is a new feature of 3.1!

0reactions
bsipoczcommented, Nov 4, 2018

@mwcraig - I suspect it’s not, I vaguely remember the sorting is relying on a new feature/API change added after the LTS (but somehow cannot find the PRs now).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot sort table by Time column #10823 - astropy ... - GitHub
I want to sort the rows by that column with Time objects. I get AttributeError: 'Time' object has no attribute 'view' error.
Read more >
Excel can't properly sort by time - Microsoft Community
I've copied 2 first columns in the new file and tried sorting there. The result is exactly the same. Yes I use multi...
Read more >
Excel date formatting NOT working? Dates not sorting in Excel?
This way, any pivot tables or charts attached to the dates will be working with valid dates and sort orders will not be...
Read more >
Solved: date/time column sort - Microsoft Power BI Community
I am trying to sort my table in ascending order by a Date/Time column. I have already formatted this column's Data Type into...
Read more >
How to Sort in Excel Rows or Columns Avoid Sort Problems
If there is a blank row or blank column in the data, part of the data might be sorted, while other data is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found