मराठी

Use the DataFrame created in Question 9 above to do the following: a) Display the row labels of Sales. b) Display the column labels of Sales. c) Display the data types of each column of Sales.

Advertisements
Advertisements

प्रश्न

Use the DataFrame created in Question 9 above to do the following:

  1. Display the row labels of Sales.
  2. Display the column labels of Sales.
  3. Display the data types of each column of Sales.
  4. Display the dimensions, shape, size and values of Sales.
  5. Display the last two rows of Sales.
  6. Display the first two columns of Sales.
  7. 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
  8. 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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 2: Data Handling using Pandas - I - Exercise [पृष्ठ ६१]

APPEARS IN

एनसीईआरटी Informatics Practices [English] Class 12
पाठ 2 Data Handling using Pandas - I
Exercise | Q 10. | पृष्ठ ६१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×