Python lists

Python Lists #

Append to list #

some_list = []

some_list.append(<some value>)

Remove from list #

some_list = [<some value>]

some_list.remove(<some value>)

Check if value in list #

some_list = [<value1>, <value2>]

# True
<value1> in some_list

# False
<value3> in some_list

Create dataframe from list of lists #

test_list = []

test1 = {
    "name": "Bob",
    "age": 12
}

test2 = {
    "name": "George",
    "age": 14
}

test_list.append([test1['name'], test1['age']])
test_list.append([test2['name'], test2['age']])
# [['Bob', 12], ['George', 14]]

pd.DataFrame(test_list, columns = ['name', 'age'])