<jupyter_start><jupyter_text>Explonatory Shop Analysis<jupyter_code>%store -r item_cat
%store -r item
%store -r sub
%store -r shops
%store -r sales_test
%store -r sales_train
%store -r __ipy
%store -r __da
__da
%%capture
__ipy

import plotly.express as px
from functools import partial
from basic_text_preprocessing import BasicPreprocessText
import googlemaps
gmaps = googlemaps.Client(key='<KEY>')
new_shops = shops.copy()
cleaned_shop_name = BasicPreprocessText().vectorize_process_text(shops['shop_name'])
new_shops['shop_name'] = cleaned_shop_name
new_shops['city'] = new_shops['shop_name'].apply(lambda x: x.split()[0])
city = new_shops['city'] .value_counts()\
.to_frame().reset_index().rename(columns={'index': 'shop_name', 'city': 'count_shops'})
px.bar(city[city['count_shops'] > 1], x='shop_name', y='count_shops')<jupyter_output><empty_output><jupyter_text>Only one store present in city<jupyter_code>city[city['count_shops'] == 1].count()
def not_city_str(x, t):
    return 1 if t in "".join(x.split()[1:]) else 0

new_shops['is_mal'] = new_shops['shop_name'].apply(partial(not_city_str, t='тц'))
new_shops['is_en_mal'] = new_shops['shop_name'].apply(partial(not_city_str, t='трк'))
def get_location(x):
    loc = gmaps.geocode(x)
    return loc[0]['geometry']['location'] if len(loc) != 0 else {'lat': 0, 'lng': 0}

locations = new_shops['shop_name'].progress_apply(get_location) 
new_shops_with_coords = pd.concat([new_shops, pd.DataFrame.from_records(locations.values)], axis=1)
new_shops_with_coords.head()
plot_data = new_shops_with_coords[new_shops_with_coords['lng'] > 0]

data = [ go.Scattergeo(
        lon = plot_data['lng'][new_shops_with_coords['lng'] > 0],
        lat = plot_data['lat'],
        text = "Shop location")]

layout = dict(
        width=1000,
        height=500,
        title = 'Locations'
    )

fig = go.Figure(data=data, layout=layout)
plotly.offline.iplot(fig)<jupyter_output><empty_output><jupyter_text>Shop count: 60<jupyter_code>print(f"Shop count: {sales_train['shop_id'].nunique()}")<jupyter_output>Shop count: 60<jupyter_text>Explonatory item Analysis Duplication of item_id. Duplication of item_id's are absent<jupyter_code>item['item_id'].shape[0] - item['item_id'].unique().shape[0]<jupyter_output><empty_output><jupyter_text>Preprocess names to find simmilar names of items:<jupyter_code>cleaned_item_name = BasicPreprocessText().vectorize_process_text(item['item_name'])
cleaned_item_name_series = pd.Series(cleaned_item_name)<jupyter_output><empty_output><jupyter_text>Duplication in item_name<jupyter_code>item['item_id'].shape[0] - cleaned_item_name_series.unique().shape[0]<jupyter_output><empty_output><jupyter_text>Item count:<jupyter_code>print(f"Item count: {sales_train['item_id'].nunique()}")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.152384367156687, 'fraction_numerical': 0.010039440659734672, 'mean_word_length': 7.829113924050633, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 32, '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': '212776', 'license': 'MIT', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1052, 'n_words': 166, 'path': 'notebooks/data_exp/sales-prediction.shops_items.python.1.0.ipynb', 'repo_name': 'Saphirox/sales-prediction', 'size': '2823'}