Answer to Question #275427 in Python for SANJAY

Question #275427

Create a dataframe by using the dataset [TITANIC.csv] and perform the following operations

i) Print the value of ‘PassengerId’ when the value of Fare is maximum and minimum.

ii) Retrieve all the rows from dataframe when the value of age of the traveller is lies between 40 and 50.

iii) Retrieve the names and gender of all the persons who was survived after the ship fell into the sea.

iv) Select and display last 10 rows from the dataframe when Fare is more than 100 and less than 200’

v) Create the newdataframe(ndf) from original dataframe(df) containing all rows and the following columns [name, ticket,’Fare]. Sort and display all values of column Name in descending order


SOLVE THIS USING PYTHON


1
Expert's answer
2021-12-04T12:12:55-0500
import pandas as pd      
data = {'Name':['C','Sharp','Corner'], 'Age':[20,21,22], 'Address':['Delhi','Kanpur','Tamil Nadu']}      
df = pd.DataFrame(data)   
df.to_csv('new.csv')  




import pandas as pd      
data = {'Name':['C','Sharp','Corner'], 'Age':[20,21,22], 'Address':['Delhi','Kanpur','Tamil Nadu']}      
df = pd.DataFrame(data)   
df.to_excel('new.xlsx')  



import pandas as pd    
df = pd.read_csv('titanic.csv', header=None, nrows=10)    
print(df)   

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS