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



Download 2,61 Mb.
bet182/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   178   179   180   181   182   183   184   185   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

describe( )



The describe method will give you a base analysis for all numerical data. You’ll be able to view min, max, 25%, 50%, mean, etc., on all columns just by calling this method on the DataFrame. This information is helpful to start your analysis but generally won’t answer those questions you’re looking for. Instead, we can use this method as a guideline of where to start:

# checking the general statistics of the DataFrame using .describe( ), only works on numerical columns df.describe( )

Go ahead and run the cell. Remember that it’ll only give back information on numerical column types, which is why we only see an output for the ages column.

sort_values( )


When you need to sort a DataFrame based on column information, you use this method. You can pass in one or multiple columns to be sorted by. When passing multiple, you must pass them in as a list of column names, in which the first name will take precedence:

# sort based on a given column, but keep the DataFrame in tact using sort_values( ) df = df.sort_values("ages") df.head(5)
Go ahead and run the cell. In this cell, we’ve re-declared the value of our df variable to our newly sorted DataFrame. This way we can view all the people sorted by age. You may also pass in an argument to sort in descending order. Filtration
Let’s look at how to filter DataFrames for information that meets a specific condition.

Conditionals


Rather than filtering out information, we can create a boolean data type column that represents the condition we’re checking. Let’s take our current DataFrame and write a condition that shows those who are 21 or older and can drink:

# using a conditional to create a true/false column to work with can_drink = df["ages"] > 21 print(can_drink)

Go ahead and run the cell. When you want to create a column based on a boolean data type, you need to write out the condition based on the entire column. Here, we created a can_drink variable that is storing the entire ages column values. They are true- false values because of our condition that we created. We could potentially use this to create another column to work with.

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   178   179   180   181   182   183   184   185   ...   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