<jupyter_start><jupyter_text>Problem1<jupyter_code>%time
dic1 = {'a':100, 'b':150, 'c':240}
dic2 = {'b':200, 'e':450, 'f':330}
dic3 = {'c':100, 'f':110, 'e':500, 'a':60}

dic_total = dic1.copy()
dic_total.update(dic2)
dic_total.update(dic3)

dic_new = dic_total.copy()

dic_items = list(dic1.items())+list(dic2.items())+list(dic3.items())
for i in dic_items:
    if i not in dic_total.items():
        dic_new[i[0]] = dic_total[i[0]] + i[1]

print(dic_new)<jupyter_output><empty_output><jupyter_text>Problem2<jupyter_code>import re, os
# os.chdir('../')
with open ('alice.txt', encoding = 'utf-8') as alice:
    alice_text = alice.read()
words = re.sub(r'[^\w\s]','',alice_text)
words = words.split()
upper_words = [word.upper() for word in words]
word_dict = dict()
for word in words:
    word_dict[word] = words.count(word)
word_dict_list = []
for i in word_dict:
    word_dict_list.append((word_dict[i], i))
sorted_word_dict_list = sorted(word_dict_list, reverse = 1)
sorted(word_dict_list, reverse = 1)<jupyter_output><empty_output><jupyter_text>Problem3<jupyter_code>with open('transactions.csv', mode = 'r') as house:
    text = house.read()
#2
text_column = [row.split(',') for row in text.split('\n')]
text_column.pop(-1)
column = []
for i in range(len(text_column[0])):
    column.append([text_column[row][i] for row in range(1,len(text_column))])
    
#3
header = text_column[0]
column_dict = dict()
for i in range(len(header)):
    column_dict[header[i]] = column[i]
import pandas as pd
pd.DataFrame(column_dict)
#3
price_list = [int(price) for price in column_dict['price']]
print('count: {}, price: {}'.format(len(column_dict['city']), sum(price_list)))
#4
city_names = set(column_dict['city'])
city_names
#5 
city_names = sorted(list(city_names))
city_names
price_dict = dict()
city_price = [(column_dict['city'][i], column_dict['price'][i]) for i in range(len(column_dict['city']))]

new_dict = dict()
for city in city_names:
    price = [int(i[1]) for i in city_price if i[0] == city]
    new_dict[city] = sum(price)/len(price)
new_dict<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1844380403458213, 'fraction_numerical': 0.027857829010566763, 'mean_word_length': 6.109215017064846, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '442571', 'license': 'MIT', 'n_tokens_mistral': 872, 'n_tokens_neox': 848, 'n_words': 166, 'path': 'Yonsei_swp06.ipynb', 'repo_name': 'AllenEdgarPoe/-', 'size': '2082'}