Here’s an example Python code that uses the pandas library to create a DataFrame and perform some basic operations on it:
import pandas as pd
# Create a dictionary with some sample data
data = {'Name': ['Alice', 'Bob', 'Charlie', 'David'],
'Age': [25, 30, 35, 40],
'Salary': [50000, 60000, 70000, 80000]}
# Create a DataFrame from the dictionary
df = pd.DataFrame(data)
# Display the DataFrame
print(df)
# Calculate some statistics on the 'Salary' column
print('Average salary:', df['Salary'].mean())
print('Minimum salary:', df['Salary'].min())
print('Maximum salary:', df['Salary'].max())
Here are results
Name Age Salary
0 Alice 25 50000
1 Bob 30 60000
2 Charlie 35 70000
3 David 40 80000
Average salary: 65000.0
Minimum salary: 50000
Maximum salary: 80000
This code creates a DataFrame from a dictionary of sample data, displays the DataFrame, and calculates some basic statistics on the ‘Salary’ column. You can modify the code to suit your own data and analysis needs.