Basic elements convert in Python
List to Dictionary
a = ['a1','a2','a3','a4']
b = ['b1','b2','b3']
d = zip(a,b)
print(dict(d)) # {'a1': 'b1', 'a2': 'b2', 'a3': 'b3'}
Use counter to obtain a aggregated form from List
from collections import Counter
counter_dic = Counter(counter_list)
Dictionary to List
list(dit) # key
list(dit.values()) # value
List to Numpy array
import numpy as np
np.array(mylist)
Numpy array to List
list(nparray)
nparray.tolist()
String to int or the reverse
int(string)
str(int)
String to list
li=['a','b','c']
print(' '.join(str(i) for i in li))
Notice that List will store the address, thus it can contain different types. For np array, all elements are the same type.