I compared "python dictionary type" and "excel function"

Reference) I made a Python text> 2.3.4 Dictionary type http://qiita.com/KatsunoriNakamura/items/b465b0cf05b1b7fd4975 http://www.k-techlabo.org/www_python/python_main.pdf#page=20

lookup function

dic = {'apple':'Apple','orange':'Mandarin orange','lemon':'Lemon'}
dicOut=dic['apple']
print('-----------------------------------------------------')
print(type('apple'),'apple')
print(type(dic)   ,dic)
print(type(dicOut),dicOut)
#<class 'str'> apple
#<class 'dict'> {'apple': 'Apple', 'orange': 'Mandarin orange', 'lemon': 'Lemon'}
#<class 'str'>Apple

sum function

dic = {'apple':50,'orange':60,'lemon': 70}
list = dic.values()
gokei= sum(list)
print('-----------------------------------------------------')
print(type(list),list)
print(type(gokei),gokei)
#<class 'dict_values'> dict_values([50, 60, 70])
#<class 'int'> 180

(Reference) I have defined list with a variable name of list in Python. http://qiita.com/k-nakamura/items/e43338e0007d79316c02

sumif function

investigating

Define a name for the cell (Name property)

Create dictionary type from Listing 1 and Listing 2

def list2dic(lst1,lst2):
    n=len(lst1)
    i=0
    dict={}
    while i<n:
       dict[lst1[i]]=lst2[i]
       i += 1
    else:
       return dict
lst1= ['apple' ,'orange', 'lemon']
lst2= ['Apple', 'Mandarin orange', 'Lemon']
lst12=list2dic(lst1,lst2)
print(type(lst12),lst12)
#<class 'dict'> {'apple': 'Apple', 'orange': 'Mandarin orange', 'lemon': 'Lemon'}

Select a specific cell or range of cells

(Reference) Changes to the built-in dict type If a list of values is absolutely necessary, cast the returned dict object. https://www.ibm.com/developerworks/jp/linux/library/l-python3-1/


myDict = {'apple':50,'orange':60,'lemon': 70}
myList = myDict.values()
myCast = list(myList)
myGokei= sum(myList)
print('-----------------------------------------------------')
print(type(myList),myList)
print(type(myCast),myCast)
print(type(myGokei),myGokei)
# <class 'dict_values'> dict_values([50, 60, 70])
# <class 'list'> [50, 60, 70]
# <class 'int'> 180

Recommended Posts

I compared "python dictionary type" and "excel function"
I compared Java and Python!
I compared python3 standard argparse and python-fire
I tried function synthesis and curry with python
I compared Python more-itertools 2.5 → 2.6
I compared blade and jinja2
I compared the speed of the reference of the python in list and the reference of the dictionary comprehension made from the in list.
Notes on Python and dictionary types
Python for super beginners Python # dictionary type 1 for super beginners
[python] week1-3: Number type and operation
I compared Qiskit and Blueqat (beginner)
I personally compared Java and Ruby
I played with PyQt5 and Python3
Function synthesis and application in Python
[Python] Difference between function and method
Python for super beginners Python # dictionary type 2 for super beginners
[Python] Function arguments * (star) and ** (double star)
I compared the speed of Hash with Topaz, Ruby and Python
I compared Node.js and Python in creating thumbnails using AWS Lambda
I replaced the numerical calculation of Python with Rust and compared the speed
python function ①
[Python] function
Dictionary type 2
Dictionary type 1
[Introduction to Udemy Python3 + Application] 24. Dictionary type
I installed and used Numba with Python3.5
Python dictionary
I compared Python's iterator and Ruby's Enumerator
Python and NumPy numeric type inheritance relationship
[Python] dictionary
Python dictionary
python function ②
I compared the speed of regular expressions in Ruby, Python, and Perl (2013 version)
I compared the moving average of IIR filter type with pandas and scipy
[Python] I tried to get the type name as a string from the type function
I want to get the file name, line number, and function name in Python 3.4
I made a python dictionary file for Neocomplete
[Python] I tried substituting the function name for the function name
[Python] I introduced Word2Vec and played with it.
I tried web scraping using python and selenium
Automatically create word and excel reports in python
First python (data type, control statement, function definition)
I wrote a class in Python3 and Java
Get multiple maximum keys in Python dictionary type
I tried Jacobian and partial differential with python
How to get dictionary type elements of Python 2.7
[Python] How to use hash function and tuple.
I implemented the inverse gamma function in python
I / O related summary of python and fortran
[Python] Class type and usage of datetime module
I read PEP-593 (Flexible function and variable annotations)
[Python] Memo dictionary
Python numeric type
python enumerate function
How to store Python function in Value of dictionary (dict) and call function according to Key
I started python
Python> function> Closure
[Python] Dictionary (hash)
Python basics: dictionary
[Python] Generator function
Python> function> Inner function