-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProg-6.py
More file actions
29 lines (22 loc) · 797 Bytes
/
Copy pathProg-6.py
File metadata and controls
29 lines (22 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pandas as pd
import numpy as np
# Sample dictionary data
exam_data = {
'name': ['Anastasia', 'Dima', 'Katherine', 'Suresh', 'Emily',
'Michael', 'Matthew', 'Laura', 'Kevin', 'Jonas'],
'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],
'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'qualify': ['yes', 'no', 'yes', 'no', 'no',
'yes', 'yes', 'no', 'no', 'yes']
}
# Index labels
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
# Create DataFrame
df = pd.DataFrame(exam_data, index=labels)
print("DataFrame:\n")
print(df)
# Get list of column headers
columns_list = df.columns.tolist()
print("\nList of column headers:")
print(columns_list)
print("\nType of columns_list:", type(columns_list))