Skip to content

Instantly share code, notes, and snippets.

@shoveller
Created July 14, 2014 09:51
Show Gist options
  • Save shoveller/c460e79a7a60c050f091 to your computer and use it in GitHub Desktop.
Save shoveller/c460e79a7a60c050f091 to your computer and use it in GitHub Desktop.
select절을 사용하듯 딕셔너리 리스트에서 특정 키값으로 가리킬 수 있는 컬럼만 추출하려면?
__author__ = 'cinos81'
if __name__ == '__main__':
testList = [{'a': 1, 'b': 2}, {'a': 'a', 'b': 'b'}]
print testList
subsetList = [{key: value for key,value in record.items() if key == 'a'} for record in testList]
print subsetList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment