# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/amindazad/GCC_Vegtables_Market/blob/main/GCC_Vegetables_Market_Analysis.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="sHW7pTWwCBRX"
# Import required libraries
import pandas as pd
import numpy as np

# + id="MQXoZXi8CUlQ"
UAE = pd.read_csv("https://raw.githubusercontent.com/amindazad/GCC_Vegtables_Market/main/UAE_Vegtables_Trade_Statistics_2015_2019.csv", header=0)
Saudi = pd.read_csv("https://raw.githubusercontent.com/amindazad/GCC_Vegtables_Market/main/Saudi_Vegtables_Trade_Statistics_2015-2019.csv", header=0)
Qatar = pd.read_csv("https://raw.githubusercontent.com/amindazad/GCC_Vegtables_Market/main/Qatar_Vetables_Trade_Statistics_2015_2019.csv", header=0)
Oman = pd.read_csv("https://raw.githubusercontent.com/amindazad/GCC_Vegtables_Market/main/Oman_Vegtables_Trade_Statistics_2015_2019.csv", header=0)
Kuwait = pd.read_csv("https://raw.githubusercontent.com/amindazad/GCC_Vegtables_Market/main/Kuwait_Vegtables_Trade_Statistics_2015_2019.csv", header=0)
Bahrain = pd.read_csv("https://raw.githubusercontent.com/amindazad/GCC_Vegtables_Market/main/Bahrain_Vegtables_Trade_Statistics_2015_2019.csv", header=0)

# + colab={"base_uri": "https://localhost:8080/", "height": 221} id="Md5n4hrdCfFW" outputId="34312c6b-2216-4fc6-96e9-75c3f06de7ec"
print(UAE.shape)
UAE.head()

# + colab={"base_uri": "https://localhost:8080/"} id="PpImqPeWqRv2" outputId="3a466f15-add4-48c2-e662-cf1c05a78b88"
# Check for NaN values
UAE.isnull().sum()

# + colab={"base_uri": "https://localhost:8080/", "height": 221} id="Z_7HjCw5D9nd" outputId="82ca98f7-5b60-44d3-a07b-6b36e7d9162b"
print(Saudi.shape)
Saudi.head()

# + colab={"base_uri": "https://localhost:8080/"} id="7yKvqpCyqb9K" outputId="3e8c1acc-c4ac-4171-a102-91da31b2efce"
# Check for NaN values
Saudi.isnull().sum()

# + colab={"base_uri": "https://localhost:8080/", "height": 221} id="xKB0Ej29EH9c" outputId="a00453b6-625e-4f04-8bdc-ba491259974a"
print(Qatar.shape)
Qatar.head()

# + colab={"base_uri": "https://localhost:8080/"} id="DPW3y8JMqeTe" outputId="8f354c3d-a7ff-4624-906a-3f3bdc128428"
# Check for NaN values
Qatar.isnull().sum()

# + colab={"base_uri": "https://localhost:8080/", "height": 419} id="THR2_JcdqgXS" outputId="0e6f51a1-aca4-461b-f38d-412f682fbb9b"
Qatar[Qatar.isna().any(axis=1)]

# + colab={"base_uri": "https://localhost:8080/", "height": 419} id="5KK9G42eqogg" outputId="1ad9a738-7aae-48c6-cab0-e4ef936aaf2c"
# Replace NaN values with the row's mean. I chose row mean because replaced
# values are specific to each product
Qatar = Qatar.T.fillna(Qatar.mean(axis=1)).T
Qatar

# + colab={"base_uri": "https://localhost:8080/", "height": 221} id="nX-zPoQ1EKps" outputId="7876936b-dcb6-4012-e22c-e47bdaddf488"
print(Oman.shape)
Oman.head()

# + colab={"base_uri": "https://localhost:8080/"} id="-q7QBa4ispDt" outputId="ab578408-6d67-461a-fe80-fe0f1c69fe42"
# Check for NaN values
Oman.isnull().sum()

# + colab={"base_uri": "https://localhost:8080/"} id="RG9VIdpItelZ" outputId="3bdd881a-eb8f-42be-d41f-07caf223758c"
# Replace NaN values with the row's mean. I chose row mean because replaced
# values are specific to each product
Oman = Oman.T.fillna(Oman.mean(axis=1)).T
Oman.isnull().sum()

# + colab={"base_uri": "https://localhost:8080/", "height": 221} id="AXeXtZ9WEPV_" outputId="7d783079-1ca8-41a3-97e3-266c77c95756"
print(Kuwait.shape)
Kuwait.head()

# + colab={"base_uri": "https://localhost:8080/"} id="tajklDUSsuRp" outputId="ad8a096a-9332-4261-b97f-c14544bacbec"
# Check for NaN values
Kuwait.isnull().sum()

# + colab={"base_uri": "https://localhost:8080/"} id="YqwuCVdWtw-D" outputId="aea05219-53d5-4e78-e8bb-1379b7b0bb98"
# Replace NaN values with the row's mean. I chose row mean because replaced
# values are specific to each product
Kuwait = Kuwait.T.fillna(Kuwait.mean(axis=1)).T
Kuwait.isnull().sum()

# + colab={"base_uri": "https://localhost:8080/", "height": 221} id="oIbme11EES8e" outputId="ebe70c6d-1483-4010-fb68-b5ed052d00cf"
print(Bahrain.shape)
Bahrain.head()

# + colab={"base_uri": "https://localhost:8080/"} id="CZ707FxUsy8F" outputId="537f73ed-20a0-4254-caa4-a02e31f470eb"
# Check for NaN values
Bahrain.isnull().sum()

# + colab={"base_uri": "https://localhost:8080/", "height": 359} id="Endez_sks5PI" outputId="9a2c83b8-db6e-41a3-e34e-cf1c593b0b9f"
Bahrain[Bahrain.isna().any(axis=1)]

# + colab={"base_uri": "https://localhost:8080/", "height": 419} id="NrwxY_zgs-Aq" outputId="e31473c8-7917-4219-a77d-8fec08309377"
Bahrain = Bahrain.T.fillna(Bahrain.mean(axis=1)).T
Bahrain

# + colab={"base_uri": "https://localhost:8080/", "height": 419} id="u4WPpAgVEXYW" outputId="12cdbf03-11a6-4899-e130-62dba8fb1212"
# Merge Datasets
df1 = pd.concat([UAE, Saudi])
df2 = pd.concat([df1, Qatar])
df3 = pd.concat([df2, Oman])
df4 = pd.concat([df3, Kuwait])
GCC = pd.concat([df4, Bahrain])
GCC

# + colab={"base_uri": "https://localhost:8080/"} id="BqIxVzRxFncr" outputId="8621fbaf-6b69-4562-b80c-ed50b9ff7e0f"
# Finding Null Values and replacing them with 0
GCC.isnull().sum()

# + colab={"base_uri": "https://localhost:8080/"} id="_lO3U714CuPi" outputId="02601c41-6788-4b8d-d7a0-777f5864f2f5"
GCC['Product label'].value_counts()

# + colab={"base_uri": "https://localhost:8080/", "height": 1000} id="l0YkASk-lGRg" outputId="cf3d5230-8345-4dd5-dccb-4b095db68fc9"
# Renaming product lables to shorter more interperetable names
GCC['Product label'] = GCC['Product label'].replace(['Fresh or chilled onions and shallots',
                                                     'Dried, shelled chickpeas "garbanzos", whether or not skinned or split',
                                                     'Garlic, fresh or chilled',
                                                     'Fresh or chilled cabbage lettuce',
                                                     'Dried, shelled lentils, whether or not skinned or split',
                                                     'Dried, shelled broad beans "Vicia faba var. major" and horse beans "Vicia faba var. equina ...',
                                                     'Fresh or chilled carrots and turnips',
                                                     'Fresh or chilled fruits of the genus Capsicum or Pimenta',
                                                     'Sweetcorn, uncooked or cooked by steaming or by boiling in water, frozen',
                                                     'Dried, shelled leguminous vegetables, whether or not skinned or split (excluding peas, chickpeas, ...',
                                                     'Fresh or chilled potatoes (excluding seed)',
                                                     'Vegetables, uncooked or cooked by steaming or by boiling in water, frozen (excluding potatoes, …',
                                                     'Arrowroot, salep, Jerusalem artichokes and similar roots and tubers with high starch or inulin ...'],
                                                    ['Fresh Onions and Shallots',
                                                     'Dried Chickpeas',
                                                     'Fresh Garlic',
                                                     'Fresh Cabbage',
                                                     'Dried Lentil',
                                                     'Dried Beans',
                                                     'Fresh Carrots & Turnips',
                                                     'Fresh Bell Peppers and Other Peppers',
                                                     'Packaged Sweetcorn',
                                                     'Dried beans',
                                                     'Fresh Potatoes (excluding seed)',
                                                     'Packaged Vegtables',
                                                     'Fresh Arrowroots'])

GCC['Product label'] = GCC['Product label'].replace(['Fresh or chilled mushrooms of the genus "Agaricus"',
                                                     'Fresh or chilled cauliflowers and headed broccoli',
                                                     'Mixtures of vegetables, uncooked or cooked by steaming or by boiling in water, frozen',
                                                     'Shelled or unshelled peas "Pisum sativum", uncooked or cooked by steaming or by boiling in …',
                                                     'Olives, provisionally preserved, e.g. by sulphur dioxide gas, in brine, in sulphur water or ...',
                                                     'Dried, shelled beans of species "Vigna mungo [L.] Hepper or Vigna radiata [L.] Wilczek", whether ...',
                                                     'Fresh or chilled leguminous vegetables, shelled or unshelled (excluding peas "Pisum sativum" ...',
                                                     'Dried, shelled peas "Pisum sativum", whether or not skinned or split',
                                                     'Fresh or chilled vegetables n.e.s.',
                                                     'Sweet potatoes, fresh, chilled, frozen or dried, whether or not sliced or in the form of pellets',
                                                     'Dried, shelled kidney beans "Phaseolus vulgaris", whether or not skinned or split',
                                                     'Shelled or unshelled beans "Vigna spp., Phaseolus spp.", uncooked or cooked by steaming or ...',
                                                     'Fresh or chilled pumpkins, squash and gourds "Cucurbita spp."'],
                                                    ['Fresh Mushrooms',
                                                     'Fresh Cauliflowers and Broccolis',
                                                     'Packaged Mixed Vegtables',
                                                     'Dried Peas',
                                                     'Packaged Olives',
                                                     'Dried Vigna Beans',
                                                     'Fresh leguminous vegetables',
                                                     'Dried shelled peas',
                                                     'Fresh n.e.s. vegtebles',
                                                     'Dried kidney beans',
                                                     'Packaged leguminous vegetables',
                                                     'Packaged Beans',
                                                     'Fresh pumpkins, squash, gourds'])

GCC['Product label'] = GCC['Product label'].replace(['Vegetables and mixtures of vegetables provisionally preserved, e.g. by sulphur dioxide gas, ...',
                                                     'Dried mushrooms and truffles, whole, cut, sliced, broken or in powder, but not further prepared ...',
                                                     'Fresh or chilled celery (excluding celeriac)',
                                                     'Fresh or chilled beans "Vigna spp., Phaseolus spp.", shelled or unshelled',
                                                     'Fresh or chilled edible mushrooms and truffles (excluding mushrooms of the genus "Agaricus")',
                                                     'Fresh or chilled asparagus',
                                                     'Fresh or chilled leguminous vegetables, shelled or unshelled (excluding peas "Pisum sativum" ...',
                                                     'Leeks and other alliaceous vegetables, fresh or chilled (excluding onions, shallots and garlic)',
                                                     'Dried vegetables and mixtures of vegetables, whole, cut, sliced, broken or in powder, but not ...',
                                                     'Spinach, New Zealand spinach and orache spinach, uncooked or cooked by steaming or by boiling ...',
                                                     'Fresh or chilled salad beetroot, salsify, celeriac, radishes and similar edible roots (excluding ...',
                                                     'Taro "Colocasia spp.", fresh, chilled, frozen or dried, whether or not sliced or in the form …',
                                                     'Dried onions, whole, cut, sliced, broken or in powder, but not further prepared"'],
                                                    ['Packaged preserved vegtables',
                                                     'Dried mushrooms and truffles',
                                                     'Fresh celery',
                                                     'Fresh Vigna Beans',
                                                     'Fresh Exotic Mushrooms',
                                                     'Fresh asparagus',
                                                     'Fresh leguminous vegetables',
                                                     'Fresh alliaceous vegetables (excluding onions, shallots and garlic)',
                                                     'Dried vegtables mix',
                                                     'Packaged spinach',
                                                     'Fresh beetroot & radishes',
                                                     'Fresh Taro',
                                                     'Dried oninons'])

GCC['Product label'] = GCC['Product label'].replace(['Potatoes, uncooked or cooked by steaming or by boiling in water, frozen',
                                                     'Cucumbers and gherkins, fresh or chilled',
                                                     'Dried, shelled small red "Adzuki" beans "Phaseolus or Vigna angularis", whether or not skinned ...',
                                                     'Brussels sprouts, fresh or chilled',
                                                     'Fresh or chilled peas "Pisum sativum", shelled or unshelled',
                                                     'Fresh or chilled spinach, New Zealand spinach and orache spinach',
                                                     'Cucumbers and gherkins provisionally preserved, e.g. by sulphur dioxide gas, in brine, in sulphur ...',
                                                     'Dried, shelled beans "Vigna and Phaseolus", whether or not skinned or split (excluding beans …',
                                                     'Fresh or chilled cabbages, kohlrabi, kale and similar edible brassicas (excluding cauliflowers, ...',
                                                     'Fresh, chilled, frozen or dried roots and tubers of manioc "cassava", whether or not sliced ...',
                                                     'Mushrooms and truffles, provisionally preserved, e.g., by sulphur dioxide gas, in brine, in …',
                                                     'Dried mushrooms of the genus "Agaricus", whole, cut, sliced, broken or in powder, but not further ...',
                                                     'Yams "Dioscorea spp.", fresh, chilled, frozen or dried, whether or not sliced or in the form ...'],
                                                    ['Packaged potatoes',
                                                     'Fresh cucumbers',
                                                     'Dried adzuki beans',
                                                     'Fresh brussels sprouts',
                                                     'Fresh peas',
                                                     'Fresh spinach',
                                                     'Packaged cucumbers',
                                                     'Dried vigna beans',
                                                     'Fresh cabbages & kale',
                                                     'Fresh cassava roots',
                                                     'Packaged mushrooms & truffles',
                                                     'Dried mushrooms',
                                                     'Fresh yams'])

GCC['Product label'] = GCC['Product label'].replace(['Fresh or chilled globe artichokes',
                                                     'Dried, shelled bambara beans "Vigna subterranea or Voandzeia subterranea", whether or not skinned ...',
                                                     'Mushrooms of the genus "Agaricus", provisionally preserved, e.g., by sulphur dioxide gas, in ...',
                                                     'Fresh or chilled lettuce (excluding cabbage lettuce)',
                                                     'Fresh or chilled aubergines "eggplants"',
                                                     'Dried, shelled cow peas "Vigna unguiculata", whether or not skinned or split',
                                                     'Fresh or chilled olives',
                                                     'Fresh or chilled witloof chicory',
                                                     'Fresh or chilled chicory (excluding witloof chicory)',
                                                     'Dried, shelled pigeon peas "Cajanus cajan", whether or not skinned or split',
                                                     'Dried wood ears "Auricularia spp.", whole, cut, sliced, broken or in powder, but not further ...',
                                                     'Dried jelly fungi "Tremella spp.", whole, cut, sliced, broken or in powder, but not further ...',
                                                     'Dried mushrooms and truffles, whole, cut, sliced, broken or in powder, but not further prepared'],
                                                    ['Fresh artichokes',
                                                     'Dried bambara beans',
                                                     'Packaged preserved mushrooms',
                                                     'Fresh lettuce',
                                                     'Fresh eggplants',
                                                     'Dried cow peas',
                                                     'Fresh olives',
                                                     'Fresh witloof chicory',
                                                     'Fresh chicory',
                                                     'Dried pigeon peas',
                                                     'Dried wood ear',
                                                     'Dried jelly fungi',
                                                     'Dried mushrooms & truffles'])

GCC['Product label'] = GCC['Product label'].replace(['Onions provisionally preserved, e.g. by sulphur dioxide gas, in brine, in sulphur water or ...'],
                                                    ['Packaged preserved onions'])

pd.set_option('max_rows', 99999)
pd.set_option('max_colwidth', 400)

GCC

# + id="Y_Eq0GJZDcyp"


StarcoderdataJupyterScriptsDedupFiltered