Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5b80c2

Browse files
committed
add pandas dataframe
1 parent 6586e9f commit c5b80c2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandasdataframe.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pandas as pd
2+
3+
simple_list = ['Sam', 'Bob', 'Joe', 'Mary', 'Sue', 'Sally']
4+
5+
named_column = {'Name': simple_list,
6+
'Favorite Color': ['Blue', 'Red', 'Green', 'Blue', 'Red', 'Green'],
7+
'Favorite Food': ['Italian', 'Mediterranean', 'Thai', 'Chinese', 'Mexican', 'Spanish']}
8+
9+
pd.set_option('display.max_columns', None)
10+
pd.set_option('display.expand_frame_repr', False)
11+
12+
data = pd.DataFrame(named_column)
13+
14+
formula_result = []
15+
for i in range(len(data)):
16+
formula_result.append(f'{data.iloc[i]["Name"]} likes {data.iloc[i]["Favorite Food"]}'
17+
f' food and the color {data.iloc[i]["Favorite Color"]}')
18+
19+
data['About Me'] = formula_result
20+
21+
print(data)

0 commit comments

Comments
 (0)