Informatics Practices
Write a Python program to create the following DataFrame using a list of dictionaries.
No | Product | Price |
---|---|---|
0 | Laptop | 60000 |
1 | Desktop | 45000 |
2 | Monitor | 15000 |
3 | Tablet | 30000 |
Python Pandas
1 Like
Answer
import pandas as pd
d1 = {'Product': 'Laptop', 'Price': 60000}
d2 = {'Product': 'Desktop', 'Price': 45000}
d3 = {'Product': 'Monitor', 'Price': 15000}
d4 = {'Product': 'Tablet', 'Price': 30000}
data = [d1, d2, d3, d4]
df = pd.DataFrame(data)
print(df)
Output
Product Price
0 Laptop 60000
1 Desktop 45000
2 Monitor 15000
3 Tablet 30000
Answered By
2 Likes
Related Questions
Complete the given Python code to get the required output (ignore the dtype attribute) as
Output:
Tamil Nadu Chennai Uttar Pradesh Lucknow Manipur Imphal
Code:
import _______ as pd data = ['Chennai','_______','Imphal'] indx = ['Tamil Nadu','Uttar Pradesh','Manipur'] s = pd.Series(_______, indx) print(_______)
Ayesha's family is replacing their old computer with a new one. They decide to throw the old computer in a nearby empty field/plot.
I. Explain any one potential environmental hazard associated with improper e-waste disposal.
II. Suggest one responsible way to Ayesha's family for proper disposal of their old computer.
III. Describe the importance of recycling in e-waste management.
Write a Python Program to create a Pandas Series as shown below using a dictionary. Note that the left column indicates the indices and the right column displays the data.
Russia Moscow Hungary Budapest Switzerland Bern I. Write an SQL statement to create a table named STUDENTS, with the following specifications:
Column Name Data Type Key StudentID Numeric Primary Key FirstName Varchar(20) LastName Varchar(10) DateOfBirth Date Percentage Float(10, 2) II. Write SQL Query to insert the following data in the Students Table
1, Supriya, Singh, 2010-08-18, 75.5