You're trying your hardest and that's enough
Welcome to another Dis or Data
Did you like that? the new sound effect? It's the sound that DataLeap is always
getting better, more refreshing and you can tap that appreciation like button
down below for more...minor improvements
If you want to be a data scientist and
make a six figure starting salary this year
then follow along with DataLeap and let us
help you bring data science down to earth
As many of you know, SQL is THE place to start when moving into data analytics
or is it? [VSauce music]
if you read the title of this
video you'd know that there is often the
challenger to sql the analysis dark knight the
manipulation ninja in the shadows the insane data frame in
the membrane pandas yes in today's Dis or Data
We are pitting these two juggernauts of data parsing against each
other in the orange corner we have sql it's
the structured query language used for storing manipulating and
retrieving data in relational databases check out the video i made praising its
many laurels up in the top right corner and yes you can touch your screen sql is
a big industry accepted tool that will net you
about almost any job excelling in inserting
and updating but putting up some barriers when it
comes to hacking yourself without a data frame already
created companies out there usually pay for a
database such as amazon redshift snowflake teradata
vantage and oracle exadata then sql is used to
interact with those existing databases in the black and white corner pandas is
a free library in free python that is free its name comes from the
term panel data an econometrics term for the data sets
that include observations over multiple time
periods for the same individuals pandas removes the need to create a data
structure for your data ahead of time and it allows you
to cleanly write your code to reproducible
effect we'll cover importing data select where insert and the update commands in
sql today and their counterparts and pandas so you
can decide for yourself whether you a savvy lifelong learner
would prefer the merits in Dis or Data.
Hi it's Andrew from DataLeap panning to the other camera
to tell you that i'm gonna start uploading three videos a week for you
after deciding that the quarantine 30 day challenge is not going to work out
for me because it's going to cause me great anxiety
and wouldn't be fair for you for the video quality
anyway back to this camera thanks andrew importing since we need to create a data
structure in order to import data in sql pandas is the clear
winner in the category in sql we need to use the create table
statement and here is the double headache not only do we
need to decide what your data fields are named we also need to know their data
types ahead of time hold on we're still not done we only
created the wrapper for the candy to softly fall into
since our data is starting out as a csv it's often the case when data scientists
receive from the data engineering team some data
so we need to use the copy command to finally finish the importing step
now this gives you more customization in the table's rigidity
and becomes a necessary step in creating tables to store specific data like email
addresses or phone numbers that have to follow
a specific pattern in order to be valid for that we'll give sql
a c for could be more convoluted on the other hand pandas cuts down the
middle man and creates an object called a data frame in
just one line of python no questions no fuss just a single read
csv method and let uncle pandas take care of the rest
that's why pandas gets an a for a little suspiciously
easy hey it's Andrew from DataLeap again panning to the other camera
to ask you if you're enjoying the new grading system if you do
it would mean a lot to me a silicon valley working professional talking to
himself in this room to smash the heck out of the like button
and watch this video to the very end all right now back to the camera select
the select statement is where sequel shines when we need to fetch records
from a table no no no no no select statement
select star from a table is a generic syntax but make sure to slap a top or
limit keyword to restrict the number of rows
you can also select each table name individually this makes me want to give
sequel an a for able and willing but pandas on the other hand
it's even simpler the head method takes the first five rows from the data frame
and you can note how many rows you need with a number between those parentheses
by default it's five the tail method is the same except for
the bottom five rows and that's something that sql cannot do
so easily for that we're going to give pandas an a for a smidge
simpler than sql seamless transition just like the masks
that filter our stinky human breaths a where clause is used to filter records
based on a condition now this is where i can go on about
conditional and logical operators and their roles as filtering conditions but
let's keep it simple in both sql and python you can apply a conditional
expressions using comparisons such as less than three or
greater than three or not equal to three or less than or equal to three
or logical operators such as or and and not does that make sense
you can also use logical operators such as or and
not and panda's equivalent jargon pipe ampersand and tilde in pandas you choose
whether you want to filter boolean or positional indexing which comes with
better control over filtering specificity and runtime
but this tends to be a much more complicated set of close
open parentheses and brackets i'm gonna give the where stamen and sql an
a for a more readable syntax and give pandas a b
for better luck next python version insert
hey i heard you like data so i put more data in your data
i'm dating myself with this meme but you get the idea we sometimes need to
insert into an existing table or data frame in sql the insert statement gets
the trick done but once again it requires you to name
the fields you want to insert manually not manually
manually by yourself in pandas the concat or append methods allow you to
insert data from other data frames or dictionaries
it's just more streamlined however it could be argued that sequel makes the
insert statement more readable and obvious well
sequel you get a b here for boring to write out by hand and pandas you get a b
for barely can read what's happening here this is probably my first hot take
and it's a good opportunity for you to comment down below if you agree
or disagree
update sometimes things change your address your phone number your
relationship status when they ask you how you are you just
have to say that but you can't just hide behind those changes you need to update
them sql once again has a readable intuitive
syntax for this kind of maneuver update whichever table name set
whichever field and add conditions so that you can precisely change
the email address of one particular customer id for example
in pandas this is not so straightforward well
it's still simple but there's no specific update command or method
all you do is locate the modification using the methods we talked about
in the where section of this video and then you can assign it to a new value a
la python variable assignment hey probably a good time to talk about
positional and boolean indexing in pandas a series of trues and falses
booleans are created whenever you filter a data
frame such as the syntax below this creates a mask of the entire data
frame called a boolean mask and that calculates the logical
condition you present to each value in order to filter the data meanwhile
positional indexing focuses on location rather than scanning through
your entire data with a boolean mask and so here are the options lock works
only on index ilock works only on position at gets
scalar values and it's a very fast lock iad also gets scalar values and it's a
very fast eye lock if this was confusing leave a comment
down below so i can go through with more vernacular but this kind of granularity
in customizing a given filter's search complexity
is the power of pandas and python so you be the judge this time
i'll wait
that's what i would have said too hi future editing andrew here
just wanted to say that this video has a lot of self promotion but in order to
become a community we really have to give so i want to take
this opportunity to say thank you for coming this far
if there's anything i can do for you ask right a follow on twitter
a code review a big tap tap on instagram let me know how i can support you so we
can start a community and write down in the comments whether or
not you think this is a new format now whether you like it
all right now let's get to drumroll the results okay so finally here are the
grades for this edition of dis or data did you bet correctly if not redeem
yourself by pressing the subscribe button and if so
darn it you win this time catch me on all these social media
twitter instagram it's all DataLeapTech not that convoluted this is part
one of the pandas versus sequel debate and i'm glad you guys
are here for the fight if you want to continue fighting down below
comment down below about what parts of the language either runtime complexity
either different requirements for different
systems either different requirements or different positions that you want to
know about pandas versus sql and i will include them in part two
which is coming out very soon once again DataLeap here. Peace!
select the select statement is where the sequels