Python Projects for Beginners a ten-Week Bootcamp Approach to Python Programming
Python Projects for Beginners A Ten Week Bootcamp Approach to Python
Just by averaging the information, we can see that adults tend to have a longer tenure. Notice that the names column was dropped. This is because groupby only keeps numerical data, as it wouldn’t be able to average out a string. groupby( ) with Multiple ColumnsWhen you need to group by multiple columns, the arguments must be passed in as a list. The first item in the list will be the main column that the DataFrame is grouped by. In our case, let’s check how many adults have a tenure of five years: # grouping information by their age group, then by their tenure df.groupby( [ "age_group", "tenure" ], as_index=False).count( ).head(10) Go ahead and run the cell. To answer the question, we needed to group by age_group first, in order to condense the information into adults and teenagers. Next, we needed to group the data further based on the tenure. This would allow us to see how many adults there are for each length of tenure. As we don’t have much data, the answer is only two. We arrive at this conclusion because we used the count method while grouping. All other tenures for each age group have only one customer. Adding a RecordTo add a record into the DataFrame, you’ll need to access the next index and assign a value as a list structure. In our case, the next index would be 7. Let’s add an identical row that already exists in our DataFrame, so we can see how to remove duplicate information in the next cell: # adding a record to the bottom of the DataFrame df.loc[7] = [ 25, "Jess", 2, "Adult" ] # add a record df.head(10) Go ahead and run the cell. This will add a new record at the bottom with the same data as our record in index 0. You won’t need to add new records too often, but it helps to know how to do it when the time comes. Download 2,61 Mb. Do'stlaringiz bilan baham: 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 |