Created
July 14, 2014 09:51
-
-
Save shoveller/c460e79a7a60c050f091 to your computer and use it in GitHub Desktop.
select절을 사용하듯 딕셔너리 리스트에서 특정 키값으로 가리킬 수 있는 컬럼만 추출하려면?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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