Python Basics
Python Basics
Good tip man! Do when numbers are massive, say in millions or billions!
You can access one item at a time, but what if you wanted to access
multiple
Doing so just assigns the rest, however many there are as a list to the
skills_dont_care.
Also, Lists are mutable – can be changed after creation i.e. new values
inserted, removed, modified etc.
Set is like a list – but written in curly braces but there is no colon here so
separate from a dictionary. Covers only unique items – e.g. it
removed python here.
Also unordered and no indexing available.
Right – Tuples very important. Very similar to lists except these are
immutable. You can add duplicate items, ordered, iterable – but in
parantheses ( ) and immutable. So you cannot do append, pop, remove
functions on this.
So, how do you really just update a tuple if you have to? There’s a
workaround – use the + operator but here too, there’s a catch. So you do
luke_skill = luke skill + new skill
Yes, it’ll update the tuple but it won’t be the same tuple – not in the same
location, will have different ids. So, inherently it will be two different
objects, not the same one proving it is immutable as you can see using
the id output above.
People often confuse identity operator with comparison operator
(=). Identity compares if x and y are both the same objects, both lie in the
same memory. You can confirm in the example above.
Had a big problem understanding how the list comprehension for 2:51:35
came about. This above is key to understand. You’re testing if the skills
that I have exist in the job roles, if yes? Then I’m qualified for the same.
Python syntax says that the condition/expression needs to come first then
the for expression for which you’re iterating. That’s why it’s
Right so (lambda x : x+3) x is the argument and x+3 is the expression.
Libraries can be packages and you can go to pipi, anaconda and download
it for a package manager. But if a package only includes things like
modules and is very basic, can’t be considered as a library.
Right so when you directly want to multiply lists/arrays like in the above
use case. Can be done directly through numpy using arrays.
You can’t do it directly for your lists because * doesn’t take a list straight
up as an operand. There are two other ways – one which I’ve been used to
and the other one is the zip function which is also nice:
Pandas is the industry standard to handle tabular data : anything excel
and CSV can handle, this can handle!
This is how we import the dataset in our Colab notebook.
Right so when you make some changes, it gets saved only in that context
unless you give the df = command.
Or by doing the above^ inplace = true ensures that the changes are
sustained.
The above command will quite literally delete columns or rows that will
have NaN values. So, we’re deleting monthly average salary entirely
because we have yearly available and then NaN values from Yearly
average.