test-conda/marketing campaigns month analysis.ipynb
Lana Rubchenia 978cdb2a61
add files
2020-10-01 14:31:49 +01:00

1 line
1.8 KiB
Plaintext

{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd \n\n#Read csv files and print needed colomns\n\ncsv_file = 'campaign_events.csv'\nrow_number = 38\ncol_list = ['Campaign', 'Event Action', 'New Users', 'Avg. Session Duration']\ndwnd_btn = ['Free start click', 'Main \\'Free Start\\' Click', 'Add Player\\' click', 'Upper Download click', 'Lower Download click']\n\ndef read_file(csv_file):\n df = pd.read_csv(csv_file, skiprows = 6, usecols = col_list)\n result = df.head(row_number)\n \n #campaign dictionary form\n campaign_dic = {}\n for _, row in result.iterrows():\n campaign_name = row['Campaign']\n action_name = row['Event Action']\n new_users = row['New Users'] \n\n if action_name in dwnd_btn:\n if campaign_name in campaign_dic:\n campaign_dic[campaign_name] += new_users \n else:\n campaign_dic[campaign_name] = new_users\n\n return campaign_dic\n\nprint(read_file(csv_file))\n","execution_count":1,"outputs":[{"name":"stdout","output_type":"stream","text":"{'29Aug-6Sep': 4.0, 'Insta Bio Free': 2.0, 'Player_Hobby_Sep16': 7.0}\n"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.7.8","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":4}