<jupyter_start><jupyter_text>Import data<jupyter_code># Import small kickstarter most backed dataset
kickstarter_small_most_backed_df = pd.read_csv(
    Path('./Resources/kickstarter_data/most_backed.csv')
)

# Fix ID column
kickstarter_small_most_backed_df.rename(columns={'Unnamed: 0': 'ID'}, inplace=True)

# Set the index as the ID
kickstarter_small_most_backed_df.set_index('ID', inplace=True)

# View head
kickstarter_small_most_backed_df.head(2)<jupyter_output><empty_output><jupyter_text>Rename cols<jupyter_code># Rename the columns to match the kickstarter large df
kickstarter_small_most_backed_df.rename(columns={'amt.pledged' : 'usd_pledged_real', 'title' : 'name', 'category' : 'main_category', 'goal' : 'usd_goal_real', 'num.backers' : 'backers'}, inplace=True)<jupyter_output><empty_output><jupyter_text>Clean df<jupyter_code># Only look at US
%run ./Resources/Utils/consts.ipynb
kickstarter_small_most_backed_df = kickstarter_small_most_backed_df[kickstarter_small_most_backed_df.loc[:,'location'].isin(city_lat_lon_dict)]

# Clean currency
kickstarter_small_most_backed_df.loc[:, 'currency'] = kickstarter_small_most_backed_df.loc[:, 'currency'].apply(lambda x : x.upper())<jupyter_output><empty_output><jupyter_text>Create dfs from selected columns<jupyter_code># List of columns to drop
kickstarter_small_cols_drop = ['blurb', 'by', 'url']

# Selected columns  df
kickstarter_selected_cols_small_most_backed_df = kickstarter_small_most_backed_df.drop(kickstarter_small_cols_drop, axis=1)<jupyter_output><empty_output><jupyter_text>Add new cols<jupyter_code># Add lat/long depends on running ./Resources/Utils/consts.ipynb first
kickstarter_selected_cols_small_most_backed_df['lat'] = kickstarter_selected_cols_small_most_backed_df['location'].apply(lambda x: city_lat_lon_dict[x][0])
kickstarter_selected_cols_small_most_backed_df['lon'] = kickstarter_selected_cols_small_most_backed_df['location'].apply(lambda x: city_lat_lon_dict[x][1])<jupyter_output><empty_output><jupyter_text>Reorder cols<jupyter_code># Base column names for reordering
small_kickstarter_order = ['name', 'main_category', 'currency', 'usd_goal_real', 'usd_pledged_real', 'location', 'backers', 'num.backers.tier', 'pledge.tier', 'lat', 'lon']

# Reorder each df
kickstarter_selected_cols_small_most_backed_df = kickstarter_selected_cols_small_most_backed_df[small_kickstarter_order]<jupyter_output><empty_output><jupyter_text>Write clean data to files<jupyter_code>kickstarter_selected_cols_small_most_backed_df.to_csv('./Resources/kickstarter_data_clean/ks-projects-small.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11414296694850115, 'fraction_numerical': 0.001921598770176787, 'mean_word_length': 11.635922330097088, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '366537', 'license': 'Unlicense', 'n_tokens_mistral': 987, 'n_tokens_neox': 915, 'n_words': 130, 'path': 'Resources/Utils/clean_kickstarter_small.ipynb', 'repo_name': 'Best-Brain-Gang/Crowdfunding_Analysis', 'size': '2602'}