딕셔너리 리스트 컬럼 추출하여 리스트 만들기

Jmnote (토론 | 기여)님의 2020년 7월 11일 (토) 19:52 판 (→‎JavaScript)

1 개요

딕셔너리 리스트 컬럼 추출하여 리스트 만들기

2 JavaScript

members = [
  { id: 102, name: 'Ashley Allen', address: 'Seoul' },
  { id: 202, name: 'Peter Parker', address: 'New York' },
  { id: 104, name: 'John Smith', address: 'Tokyo' }
]
console.log(members.map(x => x.address))
// [ 'Seoul', 'New York', 'Tokyo' ]

3 Python

members = [
    {'id': 102, 'name': "Ashley Allen", 'address': "Seoul"},
    {'id': 202, 'name': "Peter Parker", 'address': "New York"},
    {'id': 104, 'name': "John Smith", 'address': "Tokyo"},
]
print(list(m['address'] for m in members))
## ['Seoul', 'New York', 'Tokyo']
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}