Advertisements
Advertisements
प्रश्न
Use the DataFrame created in Question 9 above to do the following:
- Display the row labels of Sales.
- Display the column labels of Sales.
- Display the data types of each column of Sales.
- Display the dimensions, shape, size and values of Sales.
- Display the last two rows of Sales.
- Display the first two columns of Sales.
- Create a dictionary using the following data. Use this dictionary to create a DataFrame Sales2.
2018 Madhu 160000 Kusum 110000 Kinshuk 500000 Ankit 340000 Shruti 900000 - Check if Sales2 is empty or it contains data.
कोड लेखन
Advertisements
उत्तर
import pandas as pd
Sales = pd.DataFrame
(
{
2014: [100.5, 150.8, 200.9, 30000, 40000],
2015: [12000, 18000, 22000, 30000, 45000],
2016: [20000, 50000, 70000, 100000, 125000],
2017: [50000, 60000, 70000, 80000, 90000]
},
index=['Madhu', 'Kusum', 'Kinshuk', 'Ankit', 'Shruti']
)
print(Sales.index)
print(Sales.columns)
print(Sales.dtypes)
print(Sales.ndim)
print(Sales.shape)
print(Sales.size)
print(Sales.values)
print(Sales.tail(2))
print(Sales.iloc[:, :2])
data = {
2018: [160000, 110000, 500000, 340000, 900000]
}
Sales2 = pd.DataFrame(data, index=['Madhu', 'Kusum', 'Kinshuk', 'Ankit', 'Shruti'])
print(Sales2)
print(Sales2.empty)shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
