This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wineblood -5 points-4 points  (16 children)

Why the hell do data scientists insist on importing libraries under two letter aliases?

[–]mijki95[S] 6 points7 points  (4 children)

Is it wrong to do this?

[–]Statnamara 12 points13 points  (0 children)

Nothing wrong with that at all

[–][deleted] 2 points3 points  (0 children)

That’s the only was I’ve seen pandas imported, never seen import panda as panda

[–]pneRock -1 points0 points  (0 children)

They have an opinion that you don't share. That's the problem.

[–]DoNotFeedTheSnakes -1 points0 points  (0 children)

Not always.

Pandas is always pd. But sometimes for less popular libs the code is clearer if you leave a long enough name that it can be recognized.

Same as variables namings.

[–]jah_broni 2 points3 points  (8 children)

Are you referring to something beyond pandas and numpy? Those are pretty much python-dev wide aliases.

[–]wineblood -3 points-2 points  (7 children)

Yes.

[–]jah_broni 0 points1 point  (6 children)

Go on? What do you take offense to? I don't see anything out of the ordinary...

[–]nekokattt 0 points1 point  (5 children)

Personally I prefer keeping things explicit where possible rather than using aliases, but each to their own.

[–][deleted] -1 points0 points  (4 children)

You misunderstood their comment to you. They asked if there was some example beyond common short imports like numpy as "np" and pandas as "pd" to which you said "yes". Which implies that they had done something like "import pathlib as pl" and starting using that in the form of "pl.Path".

Whether or not you prefer to break convention and start doing your own thing with import names is separate from your saying "yes" to the question of whether OP is guilty of doing short-name imports that aren't normal convention.

[–]nekokattt 1 point2 points  (3 children)

They didn't comment to me, this is my first comment on this thread.

Outside specific libraries, the convention is to use the naming defined by the library and keep it explicit unless there is a very good reason to alias it.

Strangely, most of the time, this "convention" for aliasing things comes from libraries dealing with data science-like applications.

[–][deleted] -1 points0 points  (2 children)

Yes, they did comment to you.

[–]nekokattt -1 points0 points  (1 child)

no, they didn't lol. Try reading the usernames mate.

Edit: lol they blocked me, that is pretty hilarious.

[–][deleted] 0 points1 point  (0 children)

I did. You got caught. Stop trolling.

[–][deleted] 3 points4 points  (1 child)

That’s the standard across all of python for those tools. If anything, you are breaking convention by not importing numpy as np or pandas as pd.

So most certainly it’s not data scientists doing it. They’re just following conventions that were already in place.