SlideShare uma empresa Scribd logo
1 de 1
Baixar para ler offline
python 30 points) hi.py - experimenting with hierarchical indexing and leveling. a. (5 points)
Take the number of index levels, num_li, and the number of column levels, num_lc, from the
user. Take num_li strings, each representing labels in each index level starting from 0. Take
num_lc strings, each representing labels in each column level starting from 0 . The strings
contain labels (which are also strings) separated by a space. For example, if one of the input
strings is "foo bar baz", it means that there are three labels: "foo", "bar", and "baz" at that level.
b. (5 points) Create a DataFrame named df with num_li levels of index and num_lc levels of
column, and the labels in each level of index and column are as specified by the input strings.
Fill df with integers starting from 0 as shown in the example below. Print df. Suppose that the
values of num_li and num_lc are 2, the strings for index labels are "white white red red" and "up
down up down", and the strings for column labels are "pen pen paper paper" and "1 212 ", then
the value of df should look like this: c. (10 points) Print the sum of values in each index level
(starting from 0) and print the sum of values in each column level (starting from 0 ) in df. Also,
before each result, print which index/column level you are doing the summation. d. (10 points)
Convert df to a Series and print the Series. Hint 4: you can use the function type() to make sure
that the resulting object that you convert to is indeed a Series.

Mais conteúdo relacionado

Semelhante a python 30 points) hi.py - experimenting with hierarchical indexing a.pdf

In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
stopgolook
 
Python Cheat Sheet 2.0.pdf
Python Cheat Sheet 2.0.pdfPython Cheat Sheet 2.0.pdf
Python Cheat Sheet 2.0.pdf
Rahul Jain
 
AssignmentThe purpose of this assignment is to get you familiar .docx
AssignmentThe purpose of this assignment is to get you familiar .docxAssignmentThe purpose of this assignment is to get you familiar .docx
AssignmentThe purpose of this assignment is to get you familiar .docx
ssuser562afc1
 

Semelhante a python 30 points) hi.py - experimenting with hierarchical indexing a.pdf (20)

Functions.docx
Functions.docxFunctions.docx
Functions.docx
 
Arrays
ArraysArrays
Arrays
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework Help
 
gdscpython.pdf
gdscpython.pdfgdscpython.pdf
gdscpython.pdf
 
Basic Analysis using Python
Basic Analysis using PythonBasic Analysis using Python
Basic Analysis using Python
 
Strings and pointers
Strings and pointersStrings and pointers
Strings and pointers
 
C# slid
C# slidC# slid
C# slid
 
interenship.pptx
interenship.pptxinterenship.pptx
interenship.pptx
 
python-ch2.pptx
python-ch2.pptxpython-ch2.pptx
python-ch2.pptx
 
Programs.doc
Programs.docPrograms.doc
Programs.doc
 
AI-Programs.pdf
AI-Programs.pdfAI-Programs.pdf
AI-Programs.pdf
 
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
 
Python Cheat Sheet 2.0.pdf
Python Cheat Sheet 2.0.pdfPython Cheat Sheet 2.0.pdf
Python Cheat Sheet 2.0.pdf
 
Python programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operationsPython programming: Anonymous functions, String operations
Python programming: Anonymous functions, String operations
 
algorithm
algorithmalgorithm
algorithm
 
Csharp4 basics
Csharp4 basicsCsharp4 basics
Csharp4 basics
 
AssignmentThe purpose of this assignment is to get you familiar .docx
AssignmentThe purpose of this assignment is to get you familiar .docxAssignmentThe purpose of this assignment is to get you familiar .docx
AssignmentThe purpose of this assignment is to get you familiar .docx
 
Vizwik Coding Manual
Vizwik Coding ManualVizwik Coding Manual
Vizwik Coding Manual
 
Improve Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptxImprove Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptx
 
C++
C++C++
C++
 

Mais de alsofshionchennai

Proporcione un ejemplo de c�mo las pr�cticas deficientes de gobierno.pdf
Proporcione un ejemplo de c�mo las pr�cticas deficientes de gobierno.pdfProporcione un ejemplo de c�mo las pr�cticas deficientes de gobierno.pdf
Proporcione un ejemplo de c�mo las pr�cticas deficientes de gobierno.pdf
alsofshionchennai
 
Prompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfPrompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdf
alsofshionchennai
 
Project ScheduleUse Goods Company Inc. HRM Standardization Project.pdf
Project ScheduleUse Goods Company Inc. HRM Standardization Project.pdfProject ScheduleUse Goods Company Inc. HRM Standardization Project.pdf
Project ScheduleUse Goods Company Inc. HRM Standardization Project.pdf
alsofshionchennai
 
Program Specifications ( please show full working code that builds s.pdf
Program Specifications ( please show full working code that builds s.pdfProgram Specifications ( please show full working code that builds s.pdf
Program Specifications ( please show full working code that builds s.pdf
alsofshionchennai
 
Productos m�dicos de Penner El lunes 14 de abril, Neil Bennett, Ge.pdf
Productos m�dicos de Penner El lunes 14 de abril, Neil Bennett, Ge.pdfProductos m�dicos de Penner El lunes 14 de abril, Neil Bennett, Ge.pdf
Productos m�dicos de Penner El lunes 14 de abril, Neil Bennett, Ge.pdf
alsofshionchennai
 
Progressive Corporation (a property and casualty insurance company) .pdf
Progressive Corporation (a property and casualty insurance company) .pdfProgressive Corporation (a property and casualty insurance company) .pdf
Progressive Corporation (a property and casualty insurance company) .pdf
alsofshionchennai
 

Mais de alsofshionchennai (20)

Q15 Amabook has average variable costs of $1 and average total costs.pdf
Q15 Amabook has average variable costs of $1 and average total costs.pdfQ15 Amabook has average variable costs of $1 and average total costs.pdf
Q15 Amabook has average variable costs of $1 and average total costs.pdf
 
Provide background and analysis ono The Indian initial farmers p.pdf
Provide background and analysis ono The Indian initial farmers p.pdfProvide background and analysis ono The Indian initial farmers p.pdf
Provide background and analysis ono The Indian initial farmers p.pdf
 
Provide a detailed description for each of the following measures of.pdf
Provide a detailed description for each of the following measures of.pdfProvide a detailed description for each of the following measures of.pdf
Provide a detailed description for each of the following measures of.pdf
 
provide a brief description paragraph on the fungi, then the taxon.pdf
provide a brief description paragraph on the fungi, then the taxon.pdfprovide a brief description paragraph on the fungi, then the taxon.pdf
provide a brief description paragraph on the fungi, then the taxon.pdf
 
Proporcione un ejemplo de c�mo las pr�cticas deficientes de gobierno.pdf
Proporcione un ejemplo de c�mo las pr�cticas deficientes de gobierno.pdfProporcione un ejemplo de c�mo las pr�cticas deficientes de gobierno.pdf
Proporcione un ejemplo de c�mo las pr�cticas deficientes de gobierno.pdf
 
Prompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdfPrompt Your task is to create a connected list implementation and .pdf
Prompt Your task is to create a connected list implementation and .pdf
 
Project ScheduleUse Goods Company Inc. HRM Standardization Project.pdf
Project ScheduleUse Goods Company Inc. HRM Standardization Project.pdfProject ScheduleUse Goods Company Inc. HRM Standardization Project.pdf
Project ScheduleUse Goods Company Inc. HRM Standardization Project.pdf
 
Procedure.pdf
Procedure.pdfProcedure.pdf
Procedure.pdf
 
Project ScenarioPecos Company acquired 100 percent of Suaros outs.pdf
Project ScenarioPecos Company acquired 100 percent of Suaros outs.pdfProject ScenarioPecos Company acquired 100 percent of Suaros outs.pdf
Project ScenarioPecos Company acquired 100 percent of Suaros outs.pdf
 
Professor Jones is very particular when it comes to his morning coff.pdf
Professor Jones is very particular when it comes to his morning coff.pdfProfessor Jones is very particular when it comes to his morning coff.pdf
Professor Jones is very particular when it comes to his morning coff.pdf
 
Program Specifications ( please show full working code that builds s.pdf
Program Specifications ( please show full working code that builds s.pdfProgram Specifications ( please show full working code that builds s.pdf
Program Specifications ( please show full working code that builds s.pdf
 
Productos m�dicos de Penner El lunes 14 de abril, Neil Bennett, Ge.pdf
Productos m�dicos de Penner El lunes 14 de abril, Neil Bennett, Ge.pdfProductos m�dicos de Penner El lunes 14 de abril, Neil Bennett, Ge.pdf
Productos m�dicos de Penner El lunes 14 de abril, Neil Bennett, Ge.pdf
 
P�Pa+Ba Hice bit Holndsiteur soors places at Non bed.pdf
P�Pa+Ba Hice bit Holndsiteur soors places at Non bed.pdfP�Pa+Ba Hice bit Holndsiteur soors places at Non bed.pdf
P�Pa+Ba Hice bit Holndsiteur soors places at Non bed.pdf
 
Q1.7. What would happen if you could magically turn off decompositio.pdf
Q1.7. What would happen if you could magically turn off decompositio.pdfQ1.7. What would happen if you could magically turn off decompositio.pdf
Q1.7. What would happen if you could magically turn off decompositio.pdf
 
Progressive Corporation (a property and casualty insurance company) .pdf
Progressive Corporation (a property and casualty insurance company) .pdfProgressive Corporation (a property and casualty insurance company) .pdf
Progressive Corporation (a property and casualty insurance company) .pdf
 
Q1. (a) Briefly introduce how Force-directed algorithms encode netwo.pdf
Q1. (a) Briefly introduce how Force-directed algorithms encode netwo.pdfQ1. (a) Briefly introduce how Force-directed algorithms encode netwo.pdf
Q1. (a) Briefly introduce how Force-directed algorithms encode netwo.pdf
 
Q1. part A. can we use if statement and skip else part(ye.pdf
Q1. part A. can we use if statement and skip else part(ye.pdfQ1. part A. can we use if statement and skip else part(ye.pdf
Q1. part A. can we use if statement and skip else part(ye.pdf
 
Q1. Fiscal policy is often focused on replacing spending that is no.pdf
Q1.  Fiscal policy is often focused on replacing spending that is no.pdfQ1.  Fiscal policy is often focused on replacing spending that is no.pdf
Q1. Fiscal policy is often focused on replacing spending that is no.pdf
 
Q1 Which of the following would be considered a transport epithelium.pdf
Q1 Which of the following would be considered a transport epithelium.pdfQ1 Which of the following would be considered a transport epithelium.pdf
Q1 Which of the following would be considered a transport epithelium.pdf
 
Q1 Find two thoracic vertebrae that fit together and identify .pdf
Q1 Find two thoracic vertebrae that fit together and identify .pdfQ1 Find two thoracic vertebrae that fit together and identify .pdf
Q1 Find two thoracic vertebrae that fit together and identify .pdf
 

Último

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Último (20)

Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

python 30 points) hi.py - experimenting with hierarchical indexing a.pdf

  • 1. python 30 points) hi.py - experimenting with hierarchical indexing and leveling. a. (5 points) Take the number of index levels, num_li, and the number of column levels, num_lc, from the user. Take num_li strings, each representing labels in each index level starting from 0. Take num_lc strings, each representing labels in each column level starting from 0 . The strings contain labels (which are also strings) separated by a space. For example, if one of the input strings is "foo bar baz", it means that there are three labels: "foo", "bar", and "baz" at that level. b. (5 points) Create a DataFrame named df with num_li levels of index and num_lc levels of column, and the labels in each level of index and column are as specified by the input strings. Fill df with integers starting from 0 as shown in the example below. Print df. Suppose that the values of num_li and num_lc are 2, the strings for index labels are "white white red red" and "up down up down", and the strings for column labels are "pen pen paper paper" and "1 212 ", then the value of df should look like this: c. (10 points) Print the sum of values in each index level (starting from 0) and print the sum of values in each column level (starting from 0 ) in df. Also, before each result, print which index/column level you are doing the summation. d. (10 points) Convert df to a Series and print the Series. Hint 4: you can use the function type() to make sure that the resulting object that you convert to is indeed a Series.