Comments (6)
Can you post the full traceback?
from natsort.
C:\Windows\System32>python
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
test = [('hi','1'), ('appe','2'), ('apple',3)]
from natsort import natsort_keygen, ns
test.sort(key = natsort_keygen(key=lambda e: (e[0],e[1]), alg=ns.IC))
Traceback (most recent call last):
File "", line 1, in
File "C:\Python275\lib\site-packages\natsort\natsort.py", line 390, in _natsor
t_key
val = lowercase(val)
File "C:\Python275\lib\site-packages\natsort\locale_help.py", line 79, in
lowercase = lambda x: x.lower()
AttributeError: 'tuple' object has no attribute 'lower'
Hope that example helps! I believe this wont only happen with tuples but with any other data type that is not a string.
from natsort.
This code is in a try: except:
block that catches a TypeError
. The idea is that the code would assume a string was given, and if not, go to the branch that handles tuples/lists. Clearly, I need to update this to catch an AttributeError
as well since calling lower()
on a tuple does not raise a TypeError
.
from natsort.
Glad I could help! Your library is very useful :)
May I take this chance to ask a question, what is the performance
improvement when using fastnumbers library? I ask this because my proyect
is hosted on amazon elastic beanstalk which is a bit picky about installing
libraries, and fastnumbers needs some C code as well which would be
difficult to install on the cloud. So I was wondering if the performance
improvement is worth it or not.
On Thu, Sep 25, 2014 at 12:26 PM, Seth Morton [email protected]
wrote:
This code is in a try: except: block that catches a TypeError. The idea
is that the code would assume a string was given, and if not, go to the
branch that handles tuples/lists. Clearly, I need to update this to catch
an AttributeError as well.—
Reply to this email directly or view it on GitHub
#15 (comment).
Cristiano Coelho
_DEVELOPER_Allied South American Professionals
8 de octubre 2323 Of. 1205 - CP 11200
Tel. (+598) 2 408 1699
[email protected] [email protected]
www.asapuruguay.com
from natsort.
You should see about 30% speed improvement in the case where your strings contain only numbers; put another way, it will increase the efficiency of the string to number conversion only. Of course, in real life you are doing other string manipulations that will cause slowdowns that shadow the speed improvements of the number conversion, so the true speed improvement is really dependent on the input data and the options you choose. I recommend installing locally and testing out with your actual data.
The C code shouldn't be a problem to install... it has no library dependencies (except for Python), so if your server has a C compiler that should be all you need.
from natsort.
Check out natsort version 3.5.1, which includes this bugfix.
from natsort.
Related Issues (20)
- Wrong ordering of ordered pandas categoricals HOT 10
- Incorrect release version HOT 1
- Wrong sorting in cs_CZ.UTF-8 locale - humansorted HOT 2
- `os_sorted` fails to sort current directory HOT 3
- Wrong os_sorted sorting with special character in filename HOT 2
- Can't use natsort_keygen() as key for sorting DataFrame with MultiIndex in pandas HOT 3
- Some values don't sort in a consistent order HOT 3
- Set which OS to sort by in `os_sorted` HOT 8
- Paths should be sorted like strings HOT 6
- Loosen types and type checking
- Sorting a list of dictionaries when the sort field might or might not have a number HOT 2
- Improve os_sorted performance by avoiding `Path` roundtrips HOT 1
- add a mode for hexadecimal numbers HOT 7
- 1 test fails HOT 5
- RFE: drop use `m2r2` module HOT 8
- Sorting income category with both string and num HOT 1
- compatibility with GNU coreutils sort -n (numeric sort) HOT 14
- 'os_sorted' sorts files with spaces in names not as in Windows Explorer HOT 2
- not consistent with behavior of windows chinese edition HOT 1
- `cmp_to_key` gives an error and I don't know if this is a bug or just not supported HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from natsort.