Homework Solution: Write code to do the following: Create a data frame with the following data. What are the nam…

    Write code to do the following: 0 1) Create a data frame with the following data Name Force Jedi Sith Rebel Female Han Solo Luke Skywalker Leia Organa Obiwan Kenobi Darth Vader Anakin Skywalker Captain Phasma Ahsoka Tano Mon Mothma 2) What are the names of all the female jedi listed. 3) Create a new data frame in alphabetical order according to first names. 4) How many male rebel jedi are there?
    Write code to do the following: Create a data frame with the following data. What are the names of all the female jedi listed. Create a new data frame in alphabetical order according to first names. How many male rebel jedi are there?

    Expert Answer

     
    Hi, Below are the answers to all your questions in Python-

    Write enactment to do the subjoined: 0 1) Create a axioms establish with the subjoined axioms Name Force Jedi Sith Traitor Womanly Han Solo Luke Skywalker Leia Organa Obiwan Kenobi Darth Vader Anakin Skywalker Captain Phasma Ahsoka Tano Mon Mothma 2) What are the names of every the womanly jedi listed. 3) Create a odd axioms establish in alphabetical dispose according to chief names. 4) How multifarious hardy traitor jedi are there?

    Write enactment to do the subjoined: Create a axioms establish with the subjoined axioms. What are the names of every the womanly jedi listed. Create a odd axioms establish in alphabetical dispose according to chief names. How multifarious hardy traitor jedi are there?

    Expert Vindication

     

    Hi,

    Below are the vindications to every your questions in Python-

    Python Enactment-

    import pandas as pd
    import numpy as np
    #Vindication 1
    df = pd.DataFrame([[‘Han Solo’, ‘F’,’F’,’F’,’T’,’F’], [‘Luke Skywalker’,’T’,’T’,’F’,’T’,’F’],
    [‘Leia Organa’,’F’,’F’,’F’,’T’,’T’],[‘Obiwan Kenobi’,’T’,’T’,’F’,’T’,’F’],[‘Darth Vader’,’T’,’F’,’T’,’F’,’F’],
    [‘Anakin Skywalker’,’T’,’T’,’F’,’F’,’F’],
    [‘Captain Phasma’,’F’,’F’,’F’,’F’,’T’],
    [‘Ahsoka Tano’,’T’,’T’,’F’,’T’,’T’],
    [‘Mon Mothma’,’F’,’F’,’F’,’T’,’T’]
    ],
    columns=[‘Name’, ‘Force’,’Jedi’,’Sith’,’Rebel’,’Female’])
    print(df)

    #Vindication 2
    print(df.loc[(df[‘Female’] == ‘T’) & (df[‘Jedi’] == ‘T’)])

    #Vindication 3
    df1=df.sort_values(‘Name’)
    print(df1)

    #Vindication 4
    print(df.loc[(df[‘Female’] == ‘F’) & (df[‘Jedi’] == ‘T’)& (df[‘Rebel’] == ‘T’)])

    Screenshot-