How can I assign temp_list to every element in the column "PLAYERS"?
temp_list =['a','b']
DATE COUNTRY COUNTRY_ID COUNT PLAYERS
0 1980 United States 840 42 0
1 1980 Czech Republic 203 2 0
2 1980 New Zealand 554 3 0
3 1980 Italy 380 4 0
4 1980 Paraguay 600 2 0
5 1980 Brazil 76 3 0
6 1980 Chile 152 2 0
Create a list of lists with length same of dataframe and assign it?
In [685]: df['PLAYERS'] = [temp_list] * len(df.index)
In [686]: df
Out[686]:
DATE COUNTRY COUNTRY_ID COUNT PLAYERS
0 1980 United States 840 42 [a, b]
1 1980 Czech Republic 203 2 [a, b]
2 1980 New Zealand 554 3 [a, b]
3 1980 Italy 380 4 [a, b]
4 1980 Paraguay 600 2 [a, b]
5 1980 Brazil 76 3 [a, b]
6 1980 Chile 152 2 [a, b]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.