Python Projects for Beginners a ten-Week Bootcamp Approach to Python Programming



Download 2,61 Mb.
bet188/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   184   185   186   187   188   189   190   191   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

Inner Join


Anytime you perform a join, you need a unique column to join the data with. In our case, we can use the names column to join the ratings DataFrame with our original DataFrame. Let’s perform an inner join on these two datasets so that we can connect users with their ratings:

# performing an inner join with our df and ratings DataFrames based on names, get data that matches matched_ratings = df.merge(ratings, on="names", how="inner") matched_ratings.head( )

Go ahead and run the cell. We’ll get an output that looks like Table 10-5:
CHapter 10 INtroduCtIoN to data aNalYsIs
Table 10-5. Joining DataFrames to view customer ratings and ages together

ages

names

tenure

age_group

ratings

0 20

tyler

6

teenager

9

1 25

Jess

5

adult

10

2 29

ted

8

adult

6

Using the merge method, we were able to perform a join. By specifying the how parameter to “inner,” we were able to return a DataFrame with only those records who posted a rating. We could do a lot more with this data now than before. We could calculate average age of customers who gave us a rating, average rating per age group, etc. Joins will always help to connect separate DataFrames together, which helps especially when working with databases.

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   184   185   186   187   188   189   190   191   ...   200




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish