Skip to content

Instantly share code, notes, and snippets.

@chirag64
Created June 1, 2021 19:40
Show Gist options
  • Save chirag64/3c1f092b17781c4a4727995e0d995cb7 to your computer and use it in GitHub Desktop.
Save chirag64/3c1f092b17781c4a4727995e0d995cb7 to your computer and use it in GitHub Desktop.
Based on the amazing Udemy course on Pandas by @paskhaver
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Pandas CheatSheet",
"provenance": [],
"collapsed_sections": [
"WY3LE3_qp1Xc"
]
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"metadata": {
"id": "ahF5TCDdufy3"
},
"source": [
"pokemon_csv_url = 'https://gist.githubusercontent.com/armgilles/194bcff35001e7eb53a2a8b441e8b2c6/raw/92200bc0a673d5ce2110aaad4544ed6c4010f687/pokemon.csv'"
],
"execution_count": 47,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "rYqJTWjxltSa"
},
"source": [
"## Import pandas"
]
},
{
"cell_type": "code",
"metadata": {
"id": "dmuYgL2Rja2J"
},
"source": [
"import pandas as pd"
],
"execution_count": 2,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "WY3LE3_qp1Xc"
},
"source": [
"### Pandas Series"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ZUi1ka5jlylp"
},
"source": [
"#### Convert python list into Pandas Series object of same type"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "9pIkyOa0jeE9",
"outputId": "3f0f5536-f6e3-4cbd-f738-800765793bc0"
},
"source": [
"python_list = ['1', '2', 'a', 'b']\n",
"pd.Series(python_list)"
],
"execution_count": 6,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"0 1\n",
"1 2\n",
"2 a\n",
"3 b\n",
"dtype: object"
]
},
"metadata": {
"tags": []
},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "7RUB9PuPjweG",
"outputId": "45cd6595-1568-4579-aeab-9b574c35f690"
},
"source": [
"# Python list and pandas series of type int64\n",
"python_list = [1, 2, 3, 4, 5]\n",
"pd.Series(python_list)"
],
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"0 1\n",
"1 2\n",
"2 3\n",
"3 4\n",
"4 5\n",
"dtype: int64"
]
},
"metadata": {
"tags": []
},
"execution_count": 7
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "YXED7mCml_br"
},
"source": [
"#### Convert python dictionary into Pandas series object"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "9lkfceDMjzEX",
"outputId": "6f6c4f81-ffc6-4017-8c32-272ec7c5dc52"
},
"source": [
"python_dict = {'a': 'x', 'b': 'y', 'c': 'z'}\n",
"pd.Series(python_dict) "
],
"execution_count": 10,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"a x\n",
"b y\n",
"c z\n",
"dtype: object"
]
},
"metadata": {
"tags": []
},
"execution_count": 10
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "OCbmeyzWkh1y",
"outputId": "00fe1084-76a0-485a-efac-d38b26619407"
},
"source": [
"python_list = [1, 2, 3, 4, 5, 6]\n",
"s = pd.Series(python_list)\n",
"print(s)"
],
"execution_count": 17,
"outputs": [
{
"output_type": "stream",
"text": [
"0 1\n",
"1 2\n",
"2 3\n",
"3 4\n",
"4 5\n",
"5 6\n",
"dtype: int64\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "MeCbZie-nlsm"
},
"source": [
"#### Attributes of Pandas series"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "PnjMXuVAmelr",
"outputId": "f36873e9-a5d3-4f17-d5b3-255020304fd7"
},
"source": [
"print(s.values)\n",
"print(s.index)\n",
"print(s.dtype)"
],
"execution_count": 18,
"outputs": [
{
"output_type": "stream",
"text": [
"[1 2 3 4 5 6]\n",
"RangeIndex(start=0, stop=6, step=1)\n",
"int64\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "AYyEuBgpno-G"
},
"source": [
"#### Methods of Pandas series "
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "ynqYg9YGniHa",
"outputId": "25657f92-832e-4c9a-f2e0-9afec419c813"
},
"source": [
"print(s.sum())\n",
"print(s.product())\n",
"print(s.mean())\n",
"print(s.median())"
],
"execution_count": 23,
"outputs": [
{
"output_type": "stream",
"text": [
"21\n",
"720\n",
"3.5\n",
"3.5\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "rfj3-Fnfo3b7"
},
"source": [
"#### Parameters & Arguments"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "_Umvt9nboJFs",
"outputId": "f7ddf7a0-a6f3-4961-8b29-4c6033e0136d"
},
"source": [
"days_of_week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']\n",
"numbers = [1, 2, 3, 4, 5, 6, 7]\n",
"\n",
"print(pd.Series(numbers, days_of_week))\n",
"print()\n",
"print(pd.Series(data = numbers, index = days_of_week))"
],
"execution_count": 26,
"outputs": [
{
"output_type": "stream",
"text": [
"Monday 1\n",
"Tuesday 2\n",
"Wednesday 3\n",
"Thursday 4\n",
"Friday 5\n",
"Saturday 6\n",
"Sunday 7\n",
"dtype: int64\n",
"\n",
"Monday 1\n",
"Tuesday 2\n",
"Wednesday 3\n",
"Thursday 4\n",
"Friday 5\n",
"Saturday 6\n",
"Sunday 7\n",
"dtype: int64\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9xLs8Ao7pw1I"
},
"source": [
"#### Import CSV single column as Pandas series"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "gGD_TgJ3pMbS",
"outputId": "cd51b02c-e476-4e88-cf1d-e901e10aa370"
},
"source": [
"pokemon = pd.read_csv(pokemon_csv_url, usecols=['Name'], squeeze = True)\n",
"print(pokemon)"
],
"execution_count": 32,
"outputs": [
{
"output_type": "stream",
"text": [
"0 Bulbasaur\n",
"1 Ivysaur\n",
"2 Venusaur\n",
"3 VenusaurMega Venusaur\n",
"4 Charmander\n",
" ... \n",
"795 Diancie\n",
"796 DiancieMega Diancie\n",
"797 HoopaHoopa Confined\n",
"798 HoopaHoopa Unbound\n",
"799 Volcanion\n",
"Name: Name, Length: 800, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "07j-_iVQqwuQ"
},
"source": [
"#### Head & Tail"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "8XrfwDJBqRYV",
"outputId": "d135d97b-c517-4cd8-fe88-dbb059d77a9e"
},
"source": [
"print(pokemon.head())\n",
"print()\n",
"print(pokemon.tail())\n",
"print()\n",
"print(pokemon.head(2))"
],
"execution_count": 35,
"outputs": [
{
"output_type": "stream",
"text": [
"0 Bulbasaur\n",
"1 Ivysaur\n",
"2 Venusaur\n",
"3 VenusaurMega Venusaur\n",
"4 Charmander\n",
"Name: Name, dtype: object\n",
"\n",
"795 Diancie\n",
"796 DiancieMega Diancie\n",
"797 HoopaHoopa Confined\n",
"798 HoopaHoopa Unbound\n",
"799 Volcanion\n",
"Name: Name, dtype: object\n",
"\n",
"0 Bulbasaur\n",
"1 Ivysaur\n",
"Name: Name, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "u9Z_8nUJrCih"
},
"source": [
"#### Using Python methods with Pandas objects"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "SueK56waq2wR",
"outputId": "9142d5c9-2751-4c0b-9793-5e9a1ef0609d"
},
"source": [
"print(len(pokemon))\n",
"print(type(pokemon))\n",
"print()\n",
"print(dir(pokemon))\n",
"print()\n",
"print(sorted(pokemon))\n",
"print()\n",
"print(list(pokemon))\n",
"print()\n",
"print(dict(pokemon))\n",
"print()\n",
"print(max(pokemon))\n",
"print(min(pokemon))"
],
"execution_count": 36,
"outputs": [
{
"output_type": "stream",
"text": [
"800\n",
"<class 'pandas.core.series.Series'>\n",
"\n",
"['T', '_AXIS_LEN', '_AXIS_NAMES', '_AXIS_NUMBERS', '_AXIS_ORDERS', '_AXIS_REVERSED', '_AXIS_TO_AXIS_NUMBER', '_HANDLED_TYPES', '__abs__', '__add__', '__and__', '__annotations__', '__array__', '__array_priority__', '__array_ufunc__', '__array_wrap__', '__bool__', '__class__', '__contains__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__dict__', '__dir__', '__div__', '__divmod__', '__doc__', '__eq__', '__finalize__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__iadd__', '__iand__', '__ifloordiv__', '__imod__', '__imul__', '__init__', '__init_subclass__', '__int__', '__invert__', '__ior__', '__ipow__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__long__', '__lt__', '__matmul__', '__mod__', '__module__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__weakref__', '__xor__', '_accessors', '_add_numeric_operations', '_add_series_or_dataframe_operations', '_agg_by_level', '_agg_examples_doc', '_agg_see_also_doc', '_aggregate', '_aggregate_multiple_funcs', '_align_frame', '_align_series', '_binop', '_builtin_table', '_can_hold_na', '_check_inplace_setting', '_check_is_chained_assignment_possible', '_check_label_or_level_ambiguity', '_check_setitem_copy', '_clear_item_cache', '_clip_with_one_bound', '_clip_with_scalar', '_consolidate', '_consolidate_inplace', '_construct_axes_dict', '_construct_axes_from_arguments', '_construct_result', '_constructor', '_constructor_expanddim', '_constructor_sliced', '_convert', '_convert_dtypes', '_cython_table', '_data', '_deprecations', '_dir_additions', '_dir_deletions', '_drop_axis', '_drop_labels_or_levels', '_find_valid_index', '_get_axis', '_get_axis_name', '_get_axis_number', '_get_axis_resolvers', '_get_block_manager_axis', '_get_bool_data', '_get_cacher', '_get_cleaned_column_resolvers', '_get_cython_func', '_get_index_resolvers', '_get_item_cache', '_get_label_or_level_values', '_get_numeric_data', '_get_value', '_get_values', '_get_values_tuple', '_get_with', '_gotitem', '_index', '_indexed_same', '_info_axis', '_info_axis_name', '_info_axis_number', '_init_dict', '_init_mgr', '_internal_names', '_internal_names_set', '_is_builtin_func', '_is_cached', '_is_copy', '_is_label_or_level_reference', '_is_label_reference', '_is_level_reference', '_is_mixed_type', '_is_view', '_iset_item', '_ix', '_ixs', '_map_values', '_maybe_cache_changed', '_maybe_update_cacher', '_metadata', '_needs_reindex_multi', '_obj_with_exclusions', '_protect_consolidate', '_reduce', '_reindex_axes', '_reindex_indexer', '_reindex_multi', '_reindex_with_indexers', '_repr_data_resource_', '_repr_latex_', '_reset_cache', '_reset_cacher', '_selected_obj', '_selection', '_selection_list', '_selection_name', '_set_as_cached', '_set_axis', '_set_axis_name', '_set_is_copy', '_set_item', '_set_labels', '_set_name', '_set_value', '_set_values', '_set_with', '_set_with_engine', '_slice', '_stat_axis', '_stat_axis_name', '_stat_axis_number', '_take_with_is_copy', '_to_dict_of_blocks', '_try_aggregate_string_function', '_typ', '_update_inplace', '_validate_dtype', '_values', '_where', 'abs', 'add', 'add_prefix', 'add_suffix', 'agg', 'aggregate', 'align', 'all', 'any', 'append', 'apply', 'argmax', 'argmin', 'argsort', 'array', 'asfreq', 'asof', 'astype', 'at', 'at_time', 'attrs', 'autocorr', 'axes', 'backfill', 'between', 'between_time', 'bfill', 'bool', 'clip', 'combine', 'combine_first', 'compare', 'convert_dtypes', 'copy', 'corr', 'count', 'cov', 'cummax', 'cummin', 'cumprod', 'cumsum', 'describe', 'diff', 'div', 'divide', 'divmod', 'dot', 'drop', 'drop_duplicates', 'droplevel', 'dropna', 'dtype', 'dtypes', 'duplicated', 'empty', 'eq', 'equals', 'ewm', 'expanding', 'explode', 'factorize', 'ffill', 'fillna', 'filter', 'first', 'first_valid_index', 'floordiv', 'ge', 'get', 'groupby', 'gt', 'hasnans', 'head', 'hist', 'iat', 'idxmax', 'idxmin', 'iloc', 'index', 'infer_objects', 'interpolate', 'is_monotonic', 'is_monotonic_decreasing', 'is_monotonic_increasing', 'is_unique', 'isin', 'isna', 'isnull', 'item', 'items', 'iteritems', 'keys', 'kurt', 'kurtosis', 'last', 'last_valid_index', 'le', 'loc', 'lt', 'mad', 'map', 'mask', 'max', 'mean', 'median', 'memory_usage', 'min', 'mod', 'mode', 'mul', 'multiply', 'name', 'nbytes', 'ndim', 'ne', 'nlargest', 'notna', 'notnull', 'nsmallest', 'nunique', 'pad', 'pct_change', 'pipe', 'plot', 'pop', 'pow', 'prod', 'product', 'quantile', 'radd', 'rank', 'ravel', 'rdiv', 'rdivmod', 'reindex', 'reindex_like', 'rename', 'rename_axis', 'reorder_levels', 'repeat', 'replace', 'resample', 'reset_index', 'rfloordiv', 'rmod', 'rmul', 'rolling', 'round', 'rpow', 'rsub', 'rtruediv', 'sample', 'searchsorted', 'sem', 'set_axis', 'shape', 'shift', 'size', 'skew', 'slice_shift', 'sort_index', 'sort_values', 'squeeze', 'std', 'str', 'sub', 'subtract', 'sum', 'swapaxes', 'swaplevel', 'tail', 'take', 'to_clipboard', 'to_csv', 'to_dict', 'to_excel', 'to_frame', 'to_hdf', 'to_json', 'to_latex', 'to_list', 'to_markdown', 'to_numpy', 'to_period', 'to_pickle', 'to_sql', 'to_string', 'to_timestamp', 'to_xarray', 'transform', 'transpose', 'truediv', 'truncate', 'tz_convert', 'tz_localize', 'unique', 'unstack', 'update', 'value_counts', 'values', 'var', 'view', 'where', 'xs']\n",
"\n",
"['Abomasnow', 'AbomasnowMega Abomasnow', 'Abra', 'Absol', 'AbsolMega Absol', 'Accelgor', 'AegislashBlade Forme', 'AegislashShield Forme', 'Aerodactyl', 'AerodactylMega Aerodactyl', 'Aggron', 'AggronMega Aggron', 'Aipom', 'Alakazam', 'AlakazamMega Alakazam', 'Alomomola', 'Altaria', 'AltariaMega Altaria', 'Amaura', 'Ambipom', 'Amoonguss', 'Ampharos', 'AmpharosMega Ampharos', 'Anorith', 'Arbok', 'Arcanine', 'Arceus', 'Archen', 'Archeops', 'Ariados', 'Armaldo', 'Aromatisse', 'Aron', 'Articuno', 'Audino', 'AudinoMega Audino', 'Aurorus', 'Avalugg', 'Axew', 'Azelf', 'Azumarill', 'Azurill', 'Bagon', 'Baltoy', 'Banette', 'BanetteMega Banette', 'Barbaracle', 'Barboach', 'Basculin', 'Bastiodon', 'Bayleef', 'Beartic', 'Beautifly', 'Beedrill', 'BeedrillMega Beedrill', 'Beheeyem', 'Beldum', 'Bellossom', 'Bellsprout', 'Bergmite', 'Bibarel', 'Bidoof', 'Binacle', 'Bisharp', 'Blastoise', 'BlastoiseMega Blastoise', 'Blaziken', 'BlazikenMega Blaziken', 'Blissey', 'Blitzle', 'Boldore', 'Bonsly', 'Bouffalant', 'Braixen', 'Braviary', 'Breloom', 'Bronzong', 'Bronzor', 'Budew', 'Buizel', 'Bulbasaur', 'Buneary', 'Bunnelby', 'Burmy', 'Butterfree', 'Cacnea', 'Cacturne', 'Camerupt', 'CameruptMega Camerupt', 'Carbink', 'Carnivine', 'Carracosta', 'Carvanha', 'Cascoon', 'Castform', 'Caterpie', 'Celebi', 'Chandelure', 'Chansey', 'Charizard', 'CharizardMega Charizard X', 'CharizardMega Charizard Y', 'Charmander', 'Charmeleon', 'Chatot', 'Cherrim', 'Cherubi', 'Chesnaught', 'Chespin', 'Chikorita', 'Chimchar', 'Chimecho', 'Chinchou', 'Chingling', 'Cinccino', 'Clamperl', 'Clauncher', 'Clawitzer', 'Claydol', 'Clefable', 'Clefairy', 'Cleffa', 'Cloyster', 'Cobalion', 'Cofagrigus', 'Combee', 'Combusken', 'Conkeldurr', 'Corphish', 'Corsola', 'Cottonee', 'Cradily', 'Cranidos', 'Crawdaunt', 'Cresselia', 'Croagunk', 'Crobat', 'Croconaw', 'Crustle', 'Cryogonal', 'Cubchoo', 'Cubone', 'Cyndaquil', 'Darkrai', 'DarmanitanStandard Mode', 'DarmanitanZen Mode', 'Darumaka', 'Dedenne', 'Deerling', 'Deino', 'Delcatty', 'Delibird', 'Delphox', 'DeoxysAttack Forme', 'DeoxysDefense Forme', 'DeoxysNormal Forme', 'DeoxysSpeed Forme', 'Dewgong', 'Dewott', 'Dialga', 'Diancie', 'DiancieMega Diancie', 'Diggersby', 'Diglett', 'Ditto', 'Dodrio', 'Doduo', 'Donphan', 'Doublade', 'Dragalge', 'Dragonair', 'Dragonite', 'Drapion', 'Dratini', 'Drifblim', 'Drifloon', 'Drilbur', 'Drowzee', 'Druddigon', 'Ducklett', 'Dugtrio', 'Dunsparce', 'Duosion', 'Durant', 'Dusclops', 'Dusknoir', 'Duskull', 'Dustox', 'Dwebble', 'Eelektrik', 'Eelektross', 'Eevee', 'Ekans', 'Electabuzz', 'Electivire', 'Electrike', 'Electrode', 'Elekid', 'Elgyem', 'Emboar', 'Emolga', 'Empoleon', 'Entei', 'Escavalier', 'Espeon', 'Espurr', 'Excadrill', 'Exeggcute', 'Exeggutor', 'Exploud', \"Farfetch'd\", 'Fearow', 'Feebas', 'Fennekin', 'Feraligatr', 'Ferroseed', 'Ferrothorn', 'Finneon', 'Flaaffy', 'Flabébé', 'Flareon', 'Fletchinder', 'Fletchling', 'Floatzel', 'Floette', 'Florges', 'Flygon', 'Foongus', 'Forretress', 'Fraxure', 'Frillish', 'Froakie', 'Frogadier', 'Froslass', 'Furfrou', 'Furret', 'Gabite', 'Gallade', 'GalladeMega Gallade', 'Galvantula', 'Garbodor', 'Garchomp', 'GarchompMega Garchomp', 'Gardevoir', 'GardevoirMega Gardevoir', 'Gastly', 'Gastrodon', 'Genesect', 'Gengar', 'GengarMega Gengar', 'Geodude', 'Gible', 'Gigalith', 'Girafarig', 'GiratinaAltered Forme', 'GiratinaOrigin Forme', 'Glaceon', 'Glalie', 'GlalieMega Glalie', 'Glameow', 'Gligar', 'Gliscor', 'Gloom', 'Gogoat', 'Golbat', 'Goldeen', 'Golduck', 'Golem', 'Golett', 'Golurk', 'Goodra', 'Goomy', 'Gorebyss', 'Gothita', 'Gothitelle', 'Gothorita', 'GourgeistAverage Size', 'GourgeistLarge Size', 'GourgeistSmall Size', 'GourgeistSuper Size', 'Granbull', 'Graveler', 'Greninja', 'Grimer', 'Grotle', 'Groudon', 'GroudonPrimal Groudon', 'Grovyle', 'Growlithe', 'Grumpig', 'Gulpin', 'Gurdurr', 'Gyarados', 'GyaradosMega Gyarados', 'Happiny', 'Hariyama', 'Haunter', 'Hawlucha', 'Haxorus', 'Heatmor', 'Heatran', 'Heliolisk', 'Helioptile', 'Heracross', 'HeracrossMega Heracross', 'Herdier', 'Hippopotas', 'Hippowdon', 'Hitmonchan', 'Hitmonlee', 'Hitmontop', 'Ho-oh', 'Honchkrow', 'Honedge', 'HoopaHoopa Confined', 'HoopaHoopa Unbound', 'Hoothoot', 'Hoppip', 'Horsea', 'Houndoom', 'HoundoomMega Houndoom', 'Houndour', 'Huntail', 'Hydreigon', 'Hypno', 'Igglybuff', 'Illumise', 'Infernape', 'Inkay', 'Ivysaur', 'Jellicent', 'Jigglypuff', 'Jirachi', 'Jolteon', 'Joltik', 'Jumpluff', 'Jynx', 'Kabuto', 'Kabutops', 'Kadabra', 'Kakuna', 'Kangaskhan', 'KangaskhanMega Kangaskhan', 'Karrablast', 'Kecleon', 'KeldeoOrdinary Forme', 'KeldeoResolute Forme', 'Kingdra', 'Kingler', 'Kirlia', 'Klang', 'Klefki', 'Klink', 'Klinklang', 'Koffing', 'Krabby', 'Kricketot', 'Kricketune', 'Krokorok', 'Krookodile', 'Kyogre', 'KyogrePrimal Kyogre', 'Kyurem', 'KyuremBlack Kyurem', 'KyuremWhite Kyurem', 'Lairon', 'Lampent', 'LandorusIncarnate Forme', 'LandorusTherian Forme', 'Lanturn', 'Lapras', 'Larvesta', 'Larvitar', 'Latias', 'LatiasMega Latias', 'Latios', 'LatiosMega Latios', 'Leafeon', 'Leavanny', 'Ledian', 'Ledyba', 'Lickilicky', 'Lickitung', 'Liepard', 'Lileep', 'Lilligant', 'Lillipup', 'Linoone', 'Litleo', 'Litwick', 'Lombre', 'Lopunny', 'LopunnyMega Lopunny', 'Lotad', 'Loudred', 'Lucario', 'LucarioMega Lucario', 'Ludicolo', 'Lugia', 'Lumineon', 'Lunatone', 'Luvdisc', 'Luxio', 'Luxray', 'Machamp', 'Machoke', 'Machop', 'Magby', 'Magcargo', 'Magikarp', 'Magmar', 'Magmortar', 'Magnemite', 'Magneton', 'Magnezone', 'Makuhita', 'Malamar', 'Mamoswine', 'Manaphy', 'Mandibuzz', 'Manectric', 'ManectricMega Manectric', 'Mankey', 'Mantine', 'Mantyke', 'Maractus', 'Mareep', 'Marill', 'Marowak', 'Marshtomp', 'Masquerain', 'Mawile', 'MawileMega Mawile', 'Medicham', 'MedichamMega Medicham', 'Meditite', 'Meganium', 'MeloettaAria Forme', 'MeloettaPirouette Forme', 'MeowsticFemale', 'MeowsticMale', 'Meowth', 'Mesprit', 'Metagross', 'MetagrossMega Metagross', 'Metang', 'Metapod', 'Mew', 'Mewtwo', 'MewtwoMega Mewtwo X', 'MewtwoMega Mewtwo Y', 'Mienfoo', 'Mienshao', 'Mightyena', 'Milotic', 'Miltank', 'Mime Jr.', 'Minccino', 'Minun', 'Misdreavus', 'Mismagius', 'Moltres', 'Monferno', 'Mothim', 'Mr. Mime', 'Mudkip', 'Muk', 'Munchlax', 'Munna', 'Murkrow', 'Musharna', 'Natu', 'Nidoking', 'Nidoqueen', 'Nidoran♀', 'Nidoran♂', 'Nidorina', 'Nidorino', 'Nincada', 'Ninetales', 'Ninjask', 'Noctowl', 'Noibat', 'Noivern', 'Nosepass', 'Numel', 'Nuzleaf', 'Octillery', 'Oddish', 'Omanyte', 'Omastar', 'Onix', 'Oshawott', 'Pachirisu', 'Palkia', 'Palpitoad', 'Pancham', 'Pangoro', 'Panpour', 'Pansage', 'Pansear', 'Paras', 'Parasect', 'Patrat', 'Pawniard', 'Pelipper', 'Persian', 'Petilil', 'Phanpy', 'Phantump', 'Phione', 'Pichu', 'Pidgeot', 'PidgeotMega Pidgeot', 'Pidgeotto', 'Pidgey', 'Pidove', 'Pignite', 'Pikachu', 'Piloswine', 'Pineco', 'Pinsir', 'PinsirMega Pinsir', 'Piplup', 'Plusle', 'Politoed', 'Poliwag', 'Poliwhirl', 'Poliwrath', 'Ponyta', 'Poochyena', 'Porygon', 'Porygon-Z', 'Porygon2', 'Primeape', 'Prinplup', 'Probopass', 'Psyduck', 'PumpkabooAverage Size', 'PumpkabooLarge Size', 'PumpkabooSmall Size', 'PumpkabooSuper Size', 'Pupitar', 'Purrloin', 'Purugly', 'Pyroar', 'Quagsire', 'Quilava', 'Quilladin', 'Qwilfish', 'Raichu', 'Raikou', 'Ralts', 'Rampardos', 'Rapidash', 'Raticate', 'Rattata', 'Rayquaza', 'RayquazaMega Rayquaza', 'Regice', 'Regigigas', 'Regirock', 'Registeel', 'Relicanth', 'Remoraid', 'Reshiram', 'Reuniclus', 'Rhydon', 'Rhyhorn', 'Rhyperior', 'Riolu', 'Roggenrola', 'Roselia', 'Roserade', 'Rotom', 'RotomFan Rotom', 'RotomFrost Rotom', 'RotomHeat Rotom', 'RotomMow Rotom', 'RotomWash Rotom', 'Rufflet', 'Sableye', 'SableyeMega Sableye', 'Salamence', 'SalamenceMega Salamence', 'Samurott', 'Sandile', 'Sandshrew', 'Sandslash', 'Sawk', 'Sawsbuck', 'Scatterbug', 'Sceptile', 'SceptileMega Sceptile', 'Scizor', 'ScizorMega Scizor', 'Scolipede', 'Scrafty', 'Scraggy', 'Scyther', 'Seadra', 'Seaking', 'Sealeo', 'Seedot', 'Seel', 'Seismitoad', 'Sentret', 'Serperior', 'Servine', 'Seviper', 'Sewaddle', 'Sharpedo', 'SharpedoMega Sharpedo', 'ShayminLand Forme', 'ShayminSky Forme', 'Shedinja', 'Shelgon', 'Shellder', 'Shellos', 'Shelmet', 'Shieldon', 'Shiftry', 'Shinx', 'Shroomish', 'Shuckle', 'Shuppet', 'Sigilyph', 'Silcoon', 'Simipour', 'Simisage', 'Simisear', 'Skarmory', 'Skiddo', 'Skiploom', 'Skitty', 'Skorupi', 'Skrelp', 'Skuntank', 'Slaking', 'Slakoth', 'Sliggoo', 'Slowbro', 'SlowbroMega Slowbro', 'Slowking', 'Slowpoke', 'Slugma', 'Slurpuff', 'Smeargle', 'Smoochum', 'Sneasel', 'Snivy', 'Snorlax', 'Snorunt', 'Snover', 'Snubbull', 'Solosis', 'Solrock', 'Spearow', 'Spewpa', 'Spheal', 'Spinarak', 'Spinda', 'Spiritomb', 'Spoink', 'Spritzee', 'Squirtle', 'Stantler', 'Staraptor', 'Staravia', 'Starly', 'Starmie', 'Staryu', 'Steelix', 'SteelixMega Steelix', 'Stoutland', 'Stunfisk', 'Stunky', 'Sudowoodo', 'Suicune', 'Sunflora', 'Sunkern', 'Surskit', 'Swablu', 'Swadloon', 'Swalot', 'Swampert', 'SwampertMega Swampert', 'Swanna', 'Swellow', 'Swinub', 'Swirlix', 'Swoobat', 'Sylveon', 'Taillow', 'Talonflame', 'Tangela', 'Tangrowth', 'Tauros', 'Teddiursa', 'Tentacool', 'Tentacruel', 'Tepig', 'Terrakion', 'Throh', 'ThundurusIncarnate Forme', 'ThundurusTherian Forme', 'Timburr', 'Tirtouga', 'Togekiss', 'Togepi', 'Togetic', 'Torchic', 'Torkoal', 'TornadusIncarnate Forme', 'TornadusTherian Forme', 'Torterra', 'Totodile', 'Toxicroak', 'Tranquill', 'Trapinch', 'Treecko', 'Trevenant', 'Tropius', 'Trubbish', 'Turtwig', 'Tympole', 'Tynamo', 'Typhlosion', 'Tyranitar', 'TyranitarMega Tyranitar', 'Tyrantrum', 'Tyrogue', 'Tyrunt', 'Umbreon', 'Unfezant', 'Unown', 'Ursaring', 'Uxie', 'Vanillish', 'Vanillite', 'Vanilluxe', 'Vaporeon', 'Venipede', 'Venomoth', 'Venonat', 'Venusaur', 'VenusaurMega Venusaur', 'Vespiquen', 'Vibrava', 'Victini', 'Victreebel', 'Vigoroth', 'Vileplume', 'Virizion', 'Vivillon', 'Volbeat', 'Volcanion', 'Volcarona', 'Voltorb', 'Vullaby', 'Vulpix', 'Wailmer', 'Wailord', 'Walrein', 'Wartortle', 'Watchog', 'Weavile', 'Weedle', 'Weepinbell', 'Weezing', 'Whimsicott', 'Whirlipede', 'Whiscash', 'Whismur', 'Wigglytuff', 'Wingull', 'Wobbuffet', 'Woobat', 'Wooper', 'WormadamPlant Cloak', 'WormadamSandy Cloak', 'WormadamTrash Cloak', 'Wurmple', 'Wynaut', 'Xatu', 'Xerneas', 'Yamask', 'Yanma', 'Yanmega', 'Yveltal', 'Zangoose', 'Zapdos', 'Zebstrika', 'Zekrom', 'Zigzagoon', 'Zoroark', 'Zorua', 'Zubat', 'Zweilous', 'Zygarde50% Forme']\n",
"\n",
"['Bulbasaur', 'Ivysaur', 'Venusaur', 'VenusaurMega Venusaur', 'Charmander', 'Charmeleon', 'Charizard', 'CharizardMega Charizard X', 'CharizardMega Charizard Y', 'Squirtle', 'Wartortle', 'Blastoise', 'BlastoiseMega Blastoise', 'Caterpie', 'Metapod', 'Butterfree', 'Weedle', 'Kakuna', 'Beedrill', 'BeedrillMega Beedrill', 'Pidgey', 'Pidgeotto', 'Pidgeot', 'PidgeotMega Pidgeot', 'Rattata', 'Raticate', 'Spearow', 'Fearow', 'Ekans', 'Arbok', 'Pikachu', 'Raichu', 'Sandshrew', 'Sandslash', 'Nidoran♀', 'Nidorina', 'Nidoqueen', 'Nidoran♂', 'Nidorino', 'Nidoking', 'Clefairy', 'Clefable', 'Vulpix', 'Ninetales', 'Jigglypuff', 'Wigglytuff', 'Zubat', 'Golbat', 'Oddish', 'Gloom', 'Vileplume', 'Paras', 'Parasect', 'Venonat', 'Venomoth', 'Diglett', 'Dugtrio', 'Meowth', 'Persian', 'Psyduck', 'Golduck', 'Mankey', 'Primeape', 'Growlithe', 'Arcanine', 'Poliwag', 'Poliwhirl', 'Poliwrath', 'Abra', 'Kadabra', 'Alakazam', 'AlakazamMega Alakazam', 'Machop', 'Machoke', 'Machamp', 'Bellsprout', 'Weepinbell', 'Victreebel', 'Tentacool', 'Tentacruel', 'Geodude', 'Graveler', 'Golem', 'Ponyta', 'Rapidash', 'Slowpoke', 'Slowbro', 'SlowbroMega Slowbro', 'Magnemite', 'Magneton', \"Farfetch'd\", 'Doduo', 'Dodrio', 'Seel', 'Dewgong', 'Grimer', 'Muk', 'Shellder', 'Cloyster', 'Gastly', 'Haunter', 'Gengar', 'GengarMega Gengar', 'Onix', 'Drowzee', 'Hypno', 'Krabby', 'Kingler', 'Voltorb', 'Electrode', 'Exeggcute', 'Exeggutor', 'Cubone', 'Marowak', 'Hitmonlee', 'Hitmonchan', 'Lickitung', 'Koffing', 'Weezing', 'Rhyhorn', 'Rhydon', 'Chansey', 'Tangela', 'Kangaskhan', 'KangaskhanMega Kangaskhan', 'Horsea', 'Seadra', 'Goldeen', 'Seaking', 'Staryu', 'Starmie', 'Mr. Mime', 'Scyther', 'Jynx', 'Electabuzz', 'Magmar', 'Pinsir', 'PinsirMega Pinsir', 'Tauros', 'Magikarp', 'Gyarados', 'GyaradosMega Gyarados', 'Lapras', 'Ditto', 'Eevee', 'Vaporeon', 'Jolteon', 'Flareon', 'Porygon', 'Omanyte', 'Omastar', 'Kabuto', 'Kabutops', 'Aerodactyl', 'AerodactylMega Aerodactyl', 'Snorlax', 'Articuno', 'Zapdos', 'Moltres', 'Dratini', 'Dragonair', 'Dragonite', 'Mewtwo', 'MewtwoMega Mewtwo X', 'MewtwoMega Mewtwo Y', 'Mew', 'Chikorita', 'Bayleef', 'Meganium', 'Cyndaquil', 'Quilava', 'Typhlosion', 'Totodile', 'Croconaw', 'Feraligatr', 'Sentret', 'Furret', 'Hoothoot', 'Noctowl', 'Ledyba', 'Ledian', 'Spinarak', 'Ariados', 'Crobat', 'Chinchou', 'Lanturn', 'Pichu', 'Cleffa', 'Igglybuff', 'Togepi', 'Togetic', 'Natu', 'Xatu', 'Mareep', 'Flaaffy', 'Ampharos', 'AmpharosMega Ampharos', 'Bellossom', 'Marill', 'Azumarill', 'Sudowoodo', 'Politoed', 'Hoppip', 'Skiploom', 'Jumpluff', 'Aipom', 'Sunkern', 'Sunflora', 'Yanma', 'Wooper', 'Quagsire', 'Espeon', 'Umbreon', 'Murkrow', 'Slowking', 'Misdreavus', 'Unown', 'Wobbuffet', 'Girafarig', 'Pineco', 'Forretress', 'Dunsparce', 'Gligar', 'Steelix', 'SteelixMega Steelix', 'Snubbull', 'Granbull', 'Qwilfish', 'Scizor', 'ScizorMega Scizor', 'Shuckle', 'Heracross', 'HeracrossMega Heracross', 'Sneasel', 'Teddiursa', 'Ursaring', 'Slugma', 'Magcargo', 'Swinub', 'Piloswine', 'Corsola', 'Remoraid', 'Octillery', 'Delibird', 'Mantine', 'Skarmory', 'Houndour', 'Houndoom', 'HoundoomMega Houndoom', 'Kingdra', 'Phanpy', 'Donphan', 'Porygon2', 'Stantler', 'Smeargle', 'Tyrogue', 'Hitmontop', 'Smoochum', 'Elekid', 'Magby', 'Miltank', 'Blissey', 'Raikou', 'Entei', 'Suicune', 'Larvitar', 'Pupitar', 'Tyranitar', 'TyranitarMega Tyranitar', 'Lugia', 'Ho-oh', 'Celebi', 'Treecko', 'Grovyle', 'Sceptile', 'SceptileMega Sceptile', 'Torchic', 'Combusken', 'Blaziken', 'BlazikenMega Blaziken', 'Mudkip', 'Marshtomp', 'Swampert', 'SwampertMega Swampert', 'Poochyena', 'Mightyena', 'Zigzagoon', 'Linoone', 'Wurmple', 'Silcoon', 'Beautifly', 'Cascoon', 'Dustox', 'Lotad', 'Lombre', 'Ludicolo', 'Seedot', 'Nuzleaf', 'Shiftry', 'Taillow', 'Swellow', 'Wingull', 'Pelipper', 'Ralts', 'Kirlia', 'Gardevoir', 'GardevoirMega Gardevoir', 'Surskit', 'Masquerain', 'Shroomish', 'Breloom', 'Slakoth', 'Vigoroth', 'Slaking', 'Nincada', 'Ninjask', 'Shedinja', 'Whismur', 'Loudred', 'Exploud', 'Makuhita', 'Hariyama', 'Azurill', 'Nosepass', 'Skitty', 'Delcatty', 'Sableye', 'SableyeMega Sableye', 'Mawile', 'MawileMega Mawile', 'Aron', 'Lairon', 'Aggron', 'AggronMega Aggron', 'Meditite', 'Medicham', 'MedichamMega Medicham', 'Electrike', 'Manectric', 'ManectricMega Manectric', 'Plusle', 'Minun', 'Volbeat', 'Illumise', 'Roselia', 'Gulpin', 'Swalot', 'Carvanha', 'Sharpedo', 'SharpedoMega Sharpedo', 'Wailmer', 'Wailord', 'Numel', 'Camerupt', 'CameruptMega Camerupt', 'Torkoal', 'Spoink', 'Grumpig', 'Spinda', 'Trapinch', 'Vibrava', 'Flygon', 'Cacnea', 'Cacturne', 'Swablu', 'Altaria', 'AltariaMega Altaria', 'Zangoose', 'Seviper', 'Lunatone', 'Solrock', 'Barboach', 'Whiscash', 'Corphish', 'Crawdaunt', 'Baltoy', 'Claydol', 'Lileep', 'Cradily', 'Anorith', 'Armaldo', 'Feebas', 'Milotic', 'Castform', 'Kecleon', 'Shuppet', 'Banette', 'BanetteMega Banette', 'Duskull', 'Dusclops', 'Tropius', 'Chimecho', 'Absol', 'AbsolMega Absol', 'Wynaut', 'Snorunt', 'Glalie', 'GlalieMega Glalie', 'Spheal', 'Sealeo', 'Walrein', 'Clamperl', 'Huntail', 'Gorebyss', 'Relicanth', 'Luvdisc', 'Bagon', 'Shelgon', 'Salamence', 'SalamenceMega Salamence', 'Beldum', 'Metang', 'Metagross', 'MetagrossMega Metagross', 'Regirock', 'Regice', 'Registeel', 'Latias', 'LatiasMega Latias', 'Latios', 'LatiosMega Latios', 'Kyogre', 'KyogrePrimal Kyogre', 'Groudon', 'GroudonPrimal Groudon', 'Rayquaza', 'RayquazaMega Rayquaza', 'Jirachi', 'DeoxysNormal Forme', 'DeoxysAttack Forme', 'DeoxysDefense Forme', 'DeoxysSpeed Forme', 'Turtwig', 'Grotle', 'Torterra', 'Chimchar', 'Monferno', 'Infernape', 'Piplup', 'Prinplup', 'Empoleon', 'Starly', 'Staravia', 'Staraptor', 'Bidoof', 'Bibarel', 'Kricketot', 'Kricketune', 'Shinx', 'Luxio', 'Luxray', 'Budew', 'Roserade', 'Cranidos', 'Rampardos', 'Shieldon', 'Bastiodon', 'Burmy', 'WormadamPlant Cloak', 'WormadamSandy Cloak', 'WormadamTrash Cloak', 'Mothim', 'Combee', 'Vespiquen', 'Pachirisu', 'Buizel', 'Floatzel', 'Cherubi', 'Cherrim', 'Shellos', 'Gastrodon', 'Ambipom', 'Drifloon', 'Drifblim', 'Buneary', 'Lopunny', 'LopunnyMega Lopunny', 'Mismagius', 'Honchkrow', 'Glameow', 'Purugly', 'Chingling', 'Stunky', 'Skuntank', 'Bronzor', 'Bronzong', 'Bonsly', 'Mime Jr.', 'Happiny', 'Chatot', 'Spiritomb', 'Gible', 'Gabite', 'Garchomp', 'GarchompMega Garchomp', 'Munchlax', 'Riolu', 'Lucario', 'LucarioMega Lucario', 'Hippopotas', 'Hippowdon', 'Skorupi', 'Drapion', 'Croagunk', 'Toxicroak', 'Carnivine', 'Finneon', 'Lumineon', 'Mantyke', 'Snover', 'Abomasnow', 'AbomasnowMega Abomasnow', 'Weavile', 'Magnezone', 'Lickilicky', 'Rhyperior', 'Tangrowth', 'Electivire', 'Magmortar', 'Togekiss', 'Yanmega', 'Leafeon', 'Glaceon', 'Gliscor', 'Mamoswine', 'Porygon-Z', 'Gallade', 'GalladeMega Gallade', 'Probopass', 'Dusknoir', 'Froslass', 'Rotom', 'RotomHeat Rotom', 'RotomWash Rotom', 'RotomFrost Rotom', 'RotomFan Rotom', 'RotomMow Rotom', 'Uxie', 'Mesprit', 'Azelf', 'Dialga', 'Palkia', 'Heatran', 'Regigigas', 'GiratinaAltered Forme', 'GiratinaOrigin Forme', 'Cresselia', 'Phione', 'Manaphy', 'Darkrai', 'ShayminLand Forme', 'ShayminSky Forme', 'Arceus', 'Victini', 'Snivy', 'Servine', 'Serperior', 'Tepig', 'Pignite', 'Emboar', 'Oshawott', 'Dewott', 'Samurott', 'Patrat', 'Watchog', 'Lillipup', 'Herdier', 'Stoutland', 'Purrloin', 'Liepard', 'Pansage', 'Simisage', 'Pansear', 'Simisear', 'Panpour', 'Simipour', 'Munna', 'Musharna', 'Pidove', 'Tranquill', 'Unfezant', 'Blitzle', 'Zebstrika', 'Roggenrola', 'Boldore', 'Gigalith', 'Woobat', 'Swoobat', 'Drilbur', 'Excadrill', 'Audino', 'AudinoMega Audino', 'Timburr', 'Gurdurr', 'Conkeldurr', 'Tympole', 'Palpitoad', 'Seismitoad', 'Throh', 'Sawk', 'Sewaddle', 'Swadloon', 'Leavanny', 'Venipede', 'Whirlipede', 'Scolipede', 'Cottonee', 'Whimsicott', 'Petilil', 'Lilligant', 'Basculin', 'Sandile', 'Krokorok', 'Krookodile', 'Darumaka', 'DarmanitanStandard Mode', 'DarmanitanZen Mode', 'Maractus', 'Dwebble', 'Crustle', 'Scraggy', 'Scrafty', 'Sigilyph', 'Yamask', 'Cofagrigus', 'Tirtouga', 'Carracosta', 'Archen', 'Archeops', 'Trubbish', 'Garbodor', 'Zorua', 'Zoroark', 'Minccino', 'Cinccino', 'Gothita', 'Gothorita', 'Gothitelle', 'Solosis', 'Duosion', 'Reuniclus', 'Ducklett', 'Swanna', 'Vanillite', 'Vanillish', 'Vanilluxe', 'Deerling', 'Sawsbuck', 'Emolga', 'Karrablast', 'Escavalier', 'Foongus', 'Amoonguss', 'Frillish', 'Jellicent', 'Alomomola', 'Joltik', 'Galvantula', 'Ferroseed', 'Ferrothorn', 'Klink', 'Klang', 'Klinklang', 'Tynamo', 'Eelektrik', 'Eelektross', 'Elgyem', 'Beheeyem', 'Litwick', 'Lampent', 'Chandelure', 'Axew', 'Fraxure', 'Haxorus', 'Cubchoo', 'Beartic', 'Cryogonal', 'Shelmet', 'Accelgor', 'Stunfisk', 'Mienfoo', 'Mienshao', 'Druddigon', 'Golett', 'Golurk', 'Pawniard', 'Bisharp', 'Bouffalant', 'Rufflet', 'Braviary', 'Vullaby', 'Mandibuzz', 'Heatmor', 'Durant', 'Deino', 'Zweilous', 'Hydreigon', 'Larvesta', 'Volcarona', 'Cobalion', 'Terrakion', 'Virizion', 'TornadusIncarnate Forme', 'TornadusTherian Forme', 'ThundurusIncarnate Forme', 'ThundurusTherian Forme', 'Reshiram', 'Zekrom', 'LandorusIncarnate Forme', 'LandorusTherian Forme', 'Kyurem', 'KyuremBlack Kyurem', 'KyuremWhite Kyurem', 'KeldeoOrdinary Forme', 'KeldeoResolute Forme', 'MeloettaAria Forme', 'MeloettaPirouette Forme', 'Genesect', 'Chespin', 'Quilladin', 'Chesnaught', 'Fennekin', 'Braixen', 'Delphox', 'Froakie', 'Frogadier', 'Greninja', 'Bunnelby', 'Diggersby', 'Fletchling', 'Fletchinder', 'Talonflame', 'Scatterbug', 'Spewpa', 'Vivillon', 'Litleo', 'Pyroar', 'Flabébé', 'Floette', 'Florges', 'Skiddo', 'Gogoat', 'Pancham', 'Pangoro', 'Furfrou', 'Espurr', 'MeowsticMale', 'MeowsticFemale', 'Honedge', 'Doublade', 'AegislashBlade Forme', 'AegislashShield Forme', 'Spritzee', 'Aromatisse', 'Swirlix', 'Slurpuff', 'Inkay', 'Malamar', 'Binacle', 'Barbaracle', 'Skrelp', 'Dragalge', 'Clauncher', 'Clawitzer', 'Helioptile', 'Heliolisk', 'Tyrunt', 'Tyrantrum', 'Amaura', 'Aurorus', 'Sylveon', 'Hawlucha', 'Dedenne', 'Carbink', 'Goomy', 'Sliggoo', 'Goodra', 'Klefki', 'Phantump', 'Trevenant', 'PumpkabooAverage Size', 'PumpkabooSmall Size', 'PumpkabooLarge Size', 'PumpkabooSuper Size', 'GourgeistAverage Size', 'GourgeistSmall Size', 'GourgeistLarge Size', 'GourgeistSuper Size', 'Bergmite', 'Avalugg', 'Noibat', 'Noivern', 'Xerneas', 'Yveltal', 'Zygarde50% Forme', 'Diancie', 'DiancieMega Diancie', 'HoopaHoopa Confined', 'HoopaHoopa Unbound', 'Volcanion']\n",
"\n",
"{0: 'Bulbasaur', 1: 'Ivysaur', 2: 'Venusaur', 3: 'VenusaurMega Venusaur', 4: 'Charmander', 5: 'Charmeleon', 6: 'Charizard', 7: 'CharizardMega Charizard X', 8: 'CharizardMega Charizard Y', 9: 'Squirtle', 10: 'Wartortle', 11: 'Blastoise', 12: 'BlastoiseMega Blastoise', 13: 'Caterpie', 14: 'Metapod', 15: 'Butterfree', 16: 'Weedle', 17: 'Kakuna', 18: 'Beedrill', 19: 'BeedrillMega Beedrill', 20: 'Pidgey', 21: 'Pidgeotto', 22: 'Pidgeot', 23: 'PidgeotMega Pidgeot', 24: 'Rattata', 25: 'Raticate', 26: 'Spearow', 27: 'Fearow', 28: 'Ekans', 29: 'Arbok', 30: 'Pikachu', 31: 'Raichu', 32: 'Sandshrew', 33: 'Sandslash', 34: 'Nidoran♀', 35: 'Nidorina', 36: 'Nidoqueen', 37: 'Nidoran♂', 38: 'Nidorino', 39: 'Nidoking', 40: 'Clefairy', 41: 'Clefable', 42: 'Vulpix', 43: 'Ninetales', 44: 'Jigglypuff', 45: 'Wigglytuff', 46: 'Zubat', 47: 'Golbat', 48: 'Oddish', 49: 'Gloom', 50: 'Vileplume', 51: 'Paras', 52: 'Parasect', 53: 'Venonat', 54: 'Venomoth', 55: 'Diglett', 56: 'Dugtrio', 57: 'Meowth', 58: 'Persian', 59: 'Psyduck', 60: 'Golduck', 61: 'Mankey', 62: 'Primeape', 63: 'Growlithe', 64: 'Arcanine', 65: 'Poliwag', 66: 'Poliwhirl', 67: 'Poliwrath', 68: 'Abra', 69: 'Kadabra', 70: 'Alakazam', 71: 'AlakazamMega Alakazam', 72: 'Machop', 73: 'Machoke', 74: 'Machamp', 75: 'Bellsprout', 76: 'Weepinbell', 77: 'Victreebel', 78: 'Tentacool', 79: 'Tentacruel', 80: 'Geodude', 81: 'Graveler', 82: 'Golem', 83: 'Ponyta', 84: 'Rapidash', 85: 'Slowpoke', 86: 'Slowbro', 87: 'SlowbroMega Slowbro', 88: 'Magnemite', 89: 'Magneton', 90: \"Farfetch'd\", 91: 'Doduo', 92: 'Dodrio', 93: 'Seel', 94: 'Dewgong', 95: 'Grimer', 96: 'Muk', 97: 'Shellder', 98: 'Cloyster', 99: 'Gastly', 100: 'Haunter', 101: 'Gengar', 102: 'GengarMega Gengar', 103: 'Onix', 104: 'Drowzee', 105: 'Hypno', 106: 'Krabby', 107: 'Kingler', 108: 'Voltorb', 109: 'Electrode', 110: 'Exeggcute', 111: 'Exeggutor', 112: 'Cubone', 113: 'Marowak', 114: 'Hitmonlee', 115: 'Hitmonchan', 116: 'Lickitung', 117: 'Koffing', 118: 'Weezing', 119: 'Rhyhorn', 120: 'Rhydon', 121: 'Chansey', 122: 'Tangela', 123: 'Kangaskhan', 124: 'KangaskhanMega Kangaskhan', 125: 'Horsea', 126: 'Seadra', 127: 'Goldeen', 128: 'Seaking', 129: 'Staryu', 130: 'Starmie', 131: 'Mr. Mime', 132: 'Scyther', 133: 'Jynx', 134: 'Electabuzz', 135: 'Magmar', 136: 'Pinsir', 137: 'PinsirMega Pinsir', 138: 'Tauros', 139: 'Magikarp', 140: 'Gyarados', 141: 'GyaradosMega Gyarados', 142: 'Lapras', 143: 'Ditto', 144: 'Eevee', 145: 'Vaporeon', 146: 'Jolteon', 147: 'Flareon', 148: 'Porygon', 149: 'Omanyte', 150: 'Omastar', 151: 'Kabuto', 152: 'Kabutops', 153: 'Aerodactyl', 154: 'AerodactylMega Aerodactyl', 155: 'Snorlax', 156: 'Articuno', 157: 'Zapdos', 158: 'Moltres', 159: 'Dratini', 160: 'Dragonair', 161: 'Dragonite', 162: 'Mewtwo', 163: 'MewtwoMega Mewtwo X', 164: 'MewtwoMega Mewtwo Y', 165: 'Mew', 166: 'Chikorita', 167: 'Bayleef', 168: 'Meganium', 169: 'Cyndaquil', 170: 'Quilava', 171: 'Typhlosion', 172: 'Totodile', 173: 'Croconaw', 174: 'Feraligatr', 175: 'Sentret', 176: 'Furret', 177: 'Hoothoot', 178: 'Noctowl', 179: 'Ledyba', 180: 'Ledian', 181: 'Spinarak', 182: 'Ariados', 183: 'Crobat', 184: 'Chinchou', 185: 'Lanturn', 186: 'Pichu', 187: 'Cleffa', 188: 'Igglybuff', 189: 'Togepi', 190: 'Togetic', 191: 'Natu', 192: 'Xatu', 193: 'Mareep', 194: 'Flaaffy', 195: 'Ampharos', 196: 'AmpharosMega Ampharos', 197: 'Bellossom', 198: 'Marill', 199: 'Azumarill', 200: 'Sudowoodo', 201: 'Politoed', 202: 'Hoppip', 203: 'Skiploom', 204: 'Jumpluff', 205: 'Aipom', 206: 'Sunkern', 207: 'Sunflora', 208: 'Yanma', 209: 'Wooper', 210: 'Quagsire', 211: 'Espeon', 212: 'Umbreon', 213: 'Murkrow', 214: 'Slowking', 215: 'Misdreavus', 216: 'Unown', 217: 'Wobbuffet', 218: 'Girafarig', 219: 'Pineco', 220: 'Forretress', 221: 'Dunsparce', 222: 'Gligar', 223: 'Steelix', 224: 'SteelixMega Steelix', 225: 'Snubbull', 226: 'Granbull', 227: 'Qwilfish', 228: 'Scizor', 229: 'ScizorMega Scizor', 230: 'Shuckle', 231: 'Heracross', 232: 'HeracrossMega Heracross', 233: 'Sneasel', 234: 'Teddiursa', 235: 'Ursaring', 236: 'Slugma', 237: 'Magcargo', 238: 'Swinub', 239: 'Piloswine', 240: 'Corsola', 241: 'Remoraid', 242: 'Octillery', 243: 'Delibird', 244: 'Mantine', 245: 'Skarmory', 246: 'Houndour', 247: 'Houndoom', 248: 'HoundoomMega Houndoom', 249: 'Kingdra', 250: 'Phanpy', 251: 'Donphan', 252: 'Porygon2', 253: 'Stantler', 254: 'Smeargle', 255: 'Tyrogue', 256: 'Hitmontop', 257: 'Smoochum', 258: 'Elekid', 259: 'Magby', 260: 'Miltank', 261: 'Blissey', 262: 'Raikou', 263: 'Entei', 264: 'Suicune', 265: 'Larvitar', 266: 'Pupitar', 267: 'Tyranitar', 268: 'TyranitarMega Tyranitar', 269: 'Lugia', 270: 'Ho-oh', 271: 'Celebi', 272: 'Treecko', 273: 'Grovyle', 274: 'Sceptile', 275: 'SceptileMega Sceptile', 276: 'Torchic', 277: 'Combusken', 278: 'Blaziken', 279: 'BlazikenMega Blaziken', 280: 'Mudkip', 281: 'Marshtomp', 282: 'Swampert', 283: 'SwampertMega Swampert', 284: 'Poochyena', 285: 'Mightyena', 286: 'Zigzagoon', 287: 'Linoone', 288: 'Wurmple', 289: 'Silcoon', 290: 'Beautifly', 291: 'Cascoon', 292: 'Dustox', 293: 'Lotad', 294: 'Lombre', 295: 'Ludicolo', 296: 'Seedot', 297: 'Nuzleaf', 298: 'Shiftry', 299: 'Taillow', 300: 'Swellow', 301: 'Wingull', 302: 'Pelipper', 303: 'Ralts', 304: 'Kirlia', 305: 'Gardevoir', 306: 'GardevoirMega Gardevoir', 307: 'Surskit', 308: 'Masquerain', 309: 'Shroomish', 310: 'Breloom', 311: 'Slakoth', 312: 'Vigoroth', 313: 'Slaking', 314: 'Nincada', 315: 'Ninjask', 316: 'Shedinja', 317: 'Whismur', 318: 'Loudred', 319: 'Exploud', 320: 'Makuhita', 321: 'Hariyama', 322: 'Azurill', 323: 'Nosepass', 324: 'Skitty', 325: 'Delcatty', 326: 'Sableye', 327: 'SableyeMega Sableye', 328: 'Mawile', 329: 'MawileMega Mawile', 330: 'Aron', 331: 'Lairon', 332: 'Aggron', 333: 'AggronMega Aggron', 334: 'Meditite', 335: 'Medicham', 336: 'MedichamMega Medicham', 337: 'Electrike', 338: 'Manectric', 339: 'ManectricMega Manectric', 340: 'Plusle', 341: 'Minun', 342: 'Volbeat', 343: 'Illumise', 344: 'Roselia', 345: 'Gulpin', 346: 'Swalot', 347: 'Carvanha', 348: 'Sharpedo', 349: 'SharpedoMega Sharpedo', 350: 'Wailmer', 351: 'Wailord', 352: 'Numel', 353: 'Camerupt', 354: 'CameruptMega Camerupt', 355: 'Torkoal', 356: 'Spoink', 357: 'Grumpig', 358: 'Spinda', 359: 'Trapinch', 360: 'Vibrava', 361: 'Flygon', 362: 'Cacnea', 363: 'Cacturne', 364: 'Swablu', 365: 'Altaria', 366: 'AltariaMega Altaria', 367: 'Zangoose', 368: 'Seviper', 369: 'Lunatone', 370: 'Solrock', 371: 'Barboach', 372: 'Whiscash', 373: 'Corphish', 374: 'Crawdaunt', 375: 'Baltoy', 376: 'Claydol', 377: 'Lileep', 378: 'Cradily', 379: 'Anorith', 380: 'Armaldo', 381: 'Feebas', 382: 'Milotic', 383: 'Castform', 384: 'Kecleon', 385: 'Shuppet', 386: 'Banette', 387: 'BanetteMega Banette', 388: 'Duskull', 389: 'Dusclops', 390: 'Tropius', 391: 'Chimecho', 392: 'Absol', 393: 'AbsolMega Absol', 394: 'Wynaut', 395: 'Snorunt', 396: 'Glalie', 397: 'GlalieMega Glalie', 398: 'Spheal', 399: 'Sealeo', 400: 'Walrein', 401: 'Clamperl', 402: 'Huntail', 403: 'Gorebyss', 404: 'Relicanth', 405: 'Luvdisc', 406: 'Bagon', 407: 'Shelgon', 408: 'Salamence', 409: 'SalamenceMega Salamence', 410: 'Beldum', 411: 'Metang', 412: 'Metagross', 413: 'MetagrossMega Metagross', 414: 'Regirock', 415: 'Regice', 416: 'Registeel', 417: 'Latias', 418: 'LatiasMega Latias', 419: 'Latios', 420: 'LatiosMega Latios', 421: 'Kyogre', 422: 'KyogrePrimal Kyogre', 423: 'Groudon', 424: 'GroudonPrimal Groudon', 425: 'Rayquaza', 426: 'RayquazaMega Rayquaza', 427: 'Jirachi', 428: 'DeoxysNormal Forme', 429: 'DeoxysAttack Forme', 430: 'DeoxysDefense Forme', 431: 'DeoxysSpeed Forme', 432: 'Turtwig', 433: 'Grotle', 434: 'Torterra', 435: 'Chimchar', 436: 'Monferno', 437: 'Infernape', 438: 'Piplup', 439: 'Prinplup', 440: 'Empoleon', 441: 'Starly', 442: 'Staravia', 443: 'Staraptor', 444: 'Bidoof', 445: 'Bibarel', 446: 'Kricketot', 447: 'Kricketune', 448: 'Shinx', 449: 'Luxio', 450: 'Luxray', 451: 'Budew', 452: 'Roserade', 453: 'Cranidos', 454: 'Rampardos', 455: 'Shieldon', 456: 'Bastiodon', 457: 'Burmy', 458: 'WormadamPlant Cloak', 459: 'WormadamSandy Cloak', 460: 'WormadamTrash Cloak', 461: 'Mothim', 462: 'Combee', 463: 'Vespiquen', 464: 'Pachirisu', 465: 'Buizel', 466: 'Floatzel', 467: 'Cherubi', 468: 'Cherrim', 469: 'Shellos', 470: 'Gastrodon', 471: 'Ambipom', 472: 'Drifloon', 473: 'Drifblim', 474: 'Buneary', 475: 'Lopunny', 476: 'LopunnyMega Lopunny', 477: 'Mismagius', 478: 'Honchkrow', 479: 'Glameow', 480: 'Purugly', 481: 'Chingling', 482: 'Stunky', 483: 'Skuntank', 484: 'Bronzor', 485: 'Bronzong', 486: 'Bonsly', 487: 'Mime Jr.', 488: 'Happiny', 489: 'Chatot', 490: 'Spiritomb', 491: 'Gible', 492: 'Gabite', 493: 'Garchomp', 494: 'GarchompMega Garchomp', 495: 'Munchlax', 496: 'Riolu', 497: 'Lucario', 498: 'LucarioMega Lucario', 499: 'Hippopotas', 500: 'Hippowdon', 501: 'Skorupi', 502: 'Drapion', 503: 'Croagunk', 504: 'Toxicroak', 505: 'Carnivine', 506: 'Finneon', 507: 'Lumineon', 508: 'Mantyke', 509: 'Snover', 510: 'Abomasnow', 511: 'AbomasnowMega Abomasnow', 512: 'Weavile', 513: 'Magnezone', 514: 'Lickilicky', 515: 'Rhyperior', 516: 'Tangrowth', 517: 'Electivire', 518: 'Magmortar', 519: 'Togekiss', 520: 'Yanmega', 521: 'Leafeon', 522: 'Glaceon', 523: 'Gliscor', 524: 'Mamoswine', 525: 'Porygon-Z', 526: 'Gallade', 527: 'GalladeMega Gallade', 528: 'Probopass', 529: 'Dusknoir', 530: 'Froslass', 531: 'Rotom', 532: 'RotomHeat Rotom', 533: 'RotomWash Rotom', 534: 'RotomFrost Rotom', 535: 'RotomFan Rotom', 536: 'RotomMow Rotom', 537: 'Uxie', 538: 'Mesprit', 539: 'Azelf', 540: 'Dialga', 541: 'Palkia', 542: 'Heatran', 543: 'Regigigas', 544: 'GiratinaAltered Forme', 545: 'GiratinaOrigin Forme', 546: 'Cresselia', 547: 'Phione', 548: 'Manaphy', 549: 'Darkrai', 550: 'ShayminLand Forme', 551: 'ShayminSky Forme', 552: 'Arceus', 553: 'Victini', 554: 'Snivy', 555: 'Servine', 556: 'Serperior', 557: 'Tepig', 558: 'Pignite', 559: 'Emboar', 560: 'Oshawott', 561: 'Dewott', 562: 'Samurott', 563: 'Patrat', 564: 'Watchog', 565: 'Lillipup', 566: 'Herdier', 567: 'Stoutland', 568: 'Purrloin', 569: 'Liepard', 570: 'Pansage', 571: 'Simisage', 572: 'Pansear', 573: 'Simisear', 574: 'Panpour', 575: 'Simipour', 576: 'Munna', 577: 'Musharna', 578: 'Pidove', 579: 'Tranquill', 580: 'Unfezant', 581: 'Blitzle', 582: 'Zebstrika', 583: 'Roggenrola', 584: 'Boldore', 585: 'Gigalith', 586: 'Woobat', 587: 'Swoobat', 588: 'Drilbur', 589: 'Excadrill', 590: 'Audino', 591: 'AudinoMega Audino', 592: 'Timburr', 593: 'Gurdurr', 594: 'Conkeldurr', 595: 'Tympole', 596: 'Palpitoad', 597: 'Seismitoad', 598: 'Throh', 599: 'Sawk', 600: 'Sewaddle', 601: 'Swadloon', 602: 'Leavanny', 603: 'Venipede', 604: 'Whirlipede', 605: 'Scolipede', 606: 'Cottonee', 607: 'Whimsicott', 608: 'Petilil', 609: 'Lilligant', 610: 'Basculin', 611: 'Sandile', 612: 'Krokorok', 613: 'Krookodile', 614: 'Darumaka', 615: 'DarmanitanStandard Mode', 616: 'DarmanitanZen Mode', 617: 'Maractus', 618: 'Dwebble', 619: 'Crustle', 620: 'Scraggy', 621: 'Scrafty', 622: 'Sigilyph', 623: 'Yamask', 624: 'Cofagrigus', 625: 'Tirtouga', 626: 'Carracosta', 627: 'Archen', 628: 'Archeops', 629: 'Trubbish', 630: 'Garbodor', 631: 'Zorua', 632: 'Zoroark', 633: 'Minccino', 634: 'Cinccino', 635: 'Gothita', 636: 'Gothorita', 637: 'Gothitelle', 638: 'Solosis', 639: 'Duosion', 640: 'Reuniclus', 641: 'Ducklett', 642: 'Swanna', 643: 'Vanillite', 644: 'Vanillish', 645: 'Vanilluxe', 646: 'Deerling', 647: 'Sawsbuck', 648: 'Emolga', 649: 'Karrablast', 650: 'Escavalier', 651: 'Foongus', 652: 'Amoonguss', 653: 'Frillish', 654: 'Jellicent', 655: 'Alomomola', 656: 'Joltik', 657: 'Galvantula', 658: 'Ferroseed', 659: 'Ferrothorn', 660: 'Klink', 661: 'Klang', 662: 'Klinklang', 663: 'Tynamo', 664: 'Eelektrik', 665: 'Eelektross', 666: 'Elgyem', 667: 'Beheeyem', 668: 'Litwick', 669: 'Lampent', 670: 'Chandelure', 671: 'Axew', 672: 'Fraxure', 673: 'Haxorus', 674: 'Cubchoo', 675: 'Beartic', 676: 'Cryogonal', 677: 'Shelmet', 678: 'Accelgor', 679: 'Stunfisk', 680: 'Mienfoo', 681: 'Mienshao', 682: 'Druddigon', 683: 'Golett', 684: 'Golurk', 685: 'Pawniard', 686: 'Bisharp', 687: 'Bouffalant', 688: 'Rufflet', 689: 'Braviary', 690: 'Vullaby', 691: 'Mandibuzz', 692: 'Heatmor', 693: 'Durant', 694: 'Deino', 695: 'Zweilous', 696: 'Hydreigon', 697: 'Larvesta', 698: 'Volcarona', 699: 'Cobalion', 700: 'Terrakion', 701: 'Virizion', 702: 'TornadusIncarnate Forme', 703: 'TornadusTherian Forme', 704: 'ThundurusIncarnate Forme', 705: 'ThundurusTherian Forme', 706: 'Reshiram', 707: 'Zekrom', 708: 'LandorusIncarnate Forme', 709: 'LandorusTherian Forme', 710: 'Kyurem', 711: 'KyuremBlack Kyurem', 712: 'KyuremWhite Kyurem', 713: 'KeldeoOrdinary Forme', 714: 'KeldeoResolute Forme', 715: 'MeloettaAria Forme', 716: 'MeloettaPirouette Forme', 717: 'Genesect', 718: 'Chespin', 719: 'Quilladin', 720: 'Chesnaught', 721: 'Fennekin', 722: 'Braixen', 723: 'Delphox', 724: 'Froakie', 725: 'Frogadier', 726: 'Greninja', 727: 'Bunnelby', 728: 'Diggersby', 729: 'Fletchling', 730: 'Fletchinder', 731: 'Talonflame', 732: 'Scatterbug', 733: 'Spewpa', 734: 'Vivillon', 735: 'Litleo', 736: 'Pyroar', 737: 'Flabébé', 738: 'Floette', 739: 'Florges', 740: 'Skiddo', 741: 'Gogoat', 742: 'Pancham', 743: 'Pangoro', 744: 'Furfrou', 745: 'Espurr', 746: 'MeowsticMale', 747: 'MeowsticFemale', 748: 'Honedge', 749: 'Doublade', 750: 'AegislashBlade Forme', 751: 'AegislashShield Forme', 752: 'Spritzee', 753: 'Aromatisse', 754: 'Swirlix', 755: 'Slurpuff', 756: 'Inkay', 757: 'Malamar', 758: 'Binacle', 759: 'Barbaracle', 760: 'Skrelp', 761: 'Dragalge', 762: 'Clauncher', 763: 'Clawitzer', 764: 'Helioptile', 765: 'Heliolisk', 766: 'Tyrunt', 767: 'Tyrantrum', 768: 'Amaura', 769: 'Aurorus', 770: 'Sylveon', 771: 'Hawlucha', 772: 'Dedenne', 773: 'Carbink', 774: 'Goomy', 775: 'Sliggoo', 776: 'Goodra', 777: 'Klefki', 778: 'Phantump', 779: 'Trevenant', 780: 'PumpkabooAverage Size', 781: 'PumpkabooSmall Size', 782: 'PumpkabooLarge Size', 783: 'PumpkabooSuper Size', 784: 'GourgeistAverage Size', 785: 'GourgeistSmall Size', 786: 'GourgeistLarge Size', 787: 'GourgeistSuper Size', 788: 'Bergmite', 789: 'Avalugg', 790: 'Noibat', 791: 'Noivern', 792: 'Xerneas', 793: 'Yveltal', 794: 'Zygarde50% Forme', 795: 'Diancie', 796: 'DiancieMega Diancie', 797: 'HoopaHoopa Confined', 798: 'HoopaHoopa Unbound', 799: 'Volcanion'}\n",
"\n",
"Zygarde50% Forme\n",
"Abomasnow\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "SkDI-kckrr6Q"
},
"source": [
"#### More Pandas series attributes"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "nuyPTKnXre03",
"outputId": "1eb0e7f0-1f8d-4d52-8032-7126b16d4f0f"
},
"source": [
"print(pokemon.is_unique)\n",
"print(pokemon.ndim)\n",
"print(pokemon.shape)\n",
"print(pokemon.size)\n",
"print(pokemon.name)\n",
"print(pokemon.head())\n",
"pokemon.name = 'Pocket Monsters'\n",
"print(pokemon.head())\n"
],
"execution_count": 37,
"outputs": [
{
"output_type": "stream",
"text": [
"True\n",
"1\n",
"(800,)\n",
"800\n",
"Name\n",
"0 Bulbasaur\n",
"1 Ivysaur\n",
"2 Venusaur\n",
"3 VenusaurMega Venusaur\n",
"4 Charmander\n",
"Name: Name, dtype: object\n",
"0 Bulbasaur\n",
"1 Ivysaur\n",
"2 Venusaur\n",
"3 VenusaurMega Venusaur\n",
"4 Charmander\n",
"Name: Pocket Monsters, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "6W5DRfwYsSov"
},
"source": [
"#### Sort Values"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "4eHusTkSsXnO",
"outputId": "e3dd8ddb-f2fb-40d4-8e8d-6caa0c6abac2"
},
"source": [
"print(pokemon.sort_values().head())\n",
"print()\n",
"print(pokemon.sort_values(ascending = False).head())\n",
"print()\n",
"print(pokemon.sort_index().head())"
],
"execution_count": 41,
"outputs": [
{
"output_type": "stream",
"text": [
"510 Abomasnow\n",
"511 AbomasnowMega Abomasnow\n",
"68 Abra\n",
"392 Absol\n",
"393 AbsolMega Absol\n",
"Name: Pocket Monsters, dtype: object\n",
"\n",
"794 Zygarde50% Forme\n",
"695 Zweilous\n",
"46 Zubat\n",
"631 Zorua\n",
"632 Zoroark\n",
"Name: Pocket Monsters, dtype: object\n",
"\n",
"0 Bulbasaur\n",
"1 Ivysaur\n",
"2 Venusaur\n",
"3 VenusaurMega Venusaur\n",
"4 Charmander\n",
"Name: Pocket Monsters, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9vmrXEFxsSuD"
},
"source": [
"#### in keyword"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "1mweNlWdtPcY",
"outputId": "e0460c49-e4fd-4298-aaac-b7b1d30ebe95"
},
"source": [
"print(0 in pokemon)\n",
"print(0 in pokemon.index)\n",
"print()\n",
"print('Bulbasaur' in pokemon)\n",
"print('Bulbasaur' in pokemon.values)"
],
"execution_count": 44,
"outputs": [
{
"output_type": "stream",
"text": [
"True\n",
"True\n",
"\n",
"False\n",
"True\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "oFzWHFhKsTGn"
},
"source": [
"#### Extract values by Index"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "0rWu_NvTsKvN",
"outputId": "390c1c9e-be20-4eb2-f036-a597f13fe619"
},
"source": [
"print(pokemon[1])\n",
"print()\n",
"print(pokemon[[100, 200, 300]])\n",
"print()\n",
"print(pokemon[50:55])\n",
"print()\n",
"print(pokemon[:3])\n",
"print()\n",
"print(pokemon[-3:])\n"
],
"execution_count": 46,
"outputs": [
{
"output_type": "stream",
"text": [
"Ivysaur\n",
"\n",
"100 Haunter\n",
"200 Sudowoodo\n",
"300 Swellow\n",
"Name: Pocket Monsters, dtype: object\n",
"\n",
"50 Vileplume\n",
"51 Paras\n",
"52 Parasect\n",
"53 Venonat\n",
"54 Venomoth\n",
"Name: Pocket Monsters, dtype: object\n",
"\n",
"0 Bulbasaur\n",
"1 Ivysaur\n",
"2 Venusaur\n",
"Name: Pocket Monsters, dtype: object\n",
"\n",
"797 HoopaHoopa Confined\n",
"798 HoopaHoopa Unbound\n",
"799 Volcanion\n",
"Name: Pocket Monsters, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "GaSKPYLexfja"
},
"source": [
"#### Extract Series Values by Index Label"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "BeNhqL7FuHnL",
"outputId": "01553442-2390-414f-f22a-c19749c2ece8"
},
"source": [
"pokemon = pd.read_csv(pokemon_csv_url, index_col = ['Name'], usecols = ['Name', 'Type 1'], squeeze = True)\n",
"print(pokemon.head())\n",
"print(pokemon.index)\n",
"print(pokemon.values)"
],
"execution_count": 61,
"outputs": [
{
"output_type": "stream",
"text": [
"Name\n",
"Bulbasaur Grass\n",
"Ivysaur Grass\n",
"Venusaur Grass\n",
"VenusaurMega Venusaur Grass\n",
"Charmander Fire\n",
"Name: Type 1, dtype: object\n",
"Index(['Bulbasaur', 'Ivysaur', 'Venusaur', 'VenusaurMega Venusaur',\n",
" 'Charmander', 'Charmeleon', 'Charizard', 'CharizardMega Charizard X',\n",
" 'CharizardMega Charizard Y', 'Squirtle',\n",
" ...\n",
" 'Noibat', 'Noivern', 'Xerneas', 'Yveltal', 'Zygarde50% Forme',\n",
" 'Diancie', 'DiancieMega Diancie', 'HoopaHoopa Confined',\n",
" 'HoopaHoopa Unbound', 'Volcanion'],\n",
" dtype='object', name='Name', length=800)\n",
"['Grass' 'Grass' 'Grass' 'Grass' 'Fire' 'Fire' 'Fire' 'Fire' 'Fire'\n",
" 'Water' 'Water' 'Water' 'Water' 'Bug' 'Bug' 'Bug' 'Bug' 'Bug' 'Bug' 'Bug'\n",
" 'Normal' 'Normal' 'Normal' 'Normal' 'Normal' 'Normal' 'Normal' 'Normal'\n",
" 'Poison' 'Poison' 'Electric' 'Electric' 'Ground' 'Ground' 'Poison'\n",
" 'Poison' 'Poison' 'Poison' 'Poison' 'Poison' 'Fairy' 'Fairy' 'Fire'\n",
" 'Fire' 'Normal' 'Normal' 'Poison' 'Poison' 'Grass' 'Grass' 'Grass' 'Bug'\n",
" 'Bug' 'Bug' 'Bug' 'Ground' 'Ground' 'Normal' 'Normal' 'Water' 'Water'\n",
" 'Fighting' 'Fighting' 'Fire' 'Fire' 'Water' 'Water' 'Water' 'Psychic'\n",
" 'Psychic' 'Psychic' 'Psychic' 'Fighting' 'Fighting' 'Fighting' 'Grass'\n",
" 'Grass' 'Grass' 'Water' 'Water' 'Rock' 'Rock' 'Rock' 'Fire' 'Fire'\n",
" 'Water' 'Water' 'Water' 'Electric' 'Electric' 'Normal' 'Normal' 'Normal'\n",
" 'Water' 'Water' 'Poison' 'Poison' 'Water' 'Water' 'Ghost' 'Ghost' 'Ghost'\n",
" 'Ghost' 'Rock' 'Psychic' 'Psychic' 'Water' 'Water' 'Electric' 'Electric'\n",
" 'Grass' 'Grass' 'Ground' 'Ground' 'Fighting' 'Fighting' 'Normal' 'Poison'\n",
" 'Poison' 'Ground' 'Ground' 'Normal' 'Grass' 'Normal' 'Normal' 'Water'\n",
" 'Water' 'Water' 'Water' 'Water' 'Water' 'Psychic' 'Bug' 'Ice' 'Electric'\n",
" 'Fire' 'Bug' 'Bug' 'Normal' 'Water' 'Water' 'Water' 'Water' 'Normal'\n",
" 'Normal' 'Water' 'Electric' 'Fire' 'Normal' 'Rock' 'Rock' 'Rock' 'Rock'\n",
" 'Rock' 'Rock' 'Normal' 'Ice' 'Electric' 'Fire' 'Dragon' 'Dragon' 'Dragon'\n",
" 'Psychic' 'Psychic' 'Psychic' 'Psychic' 'Grass' 'Grass' 'Grass' 'Fire'\n",
" 'Fire' 'Fire' 'Water' 'Water' 'Water' 'Normal' 'Normal' 'Normal' 'Normal'\n",
" 'Bug' 'Bug' 'Bug' 'Bug' 'Poison' 'Water' 'Water' 'Electric' 'Fairy'\n",
" 'Normal' 'Fairy' 'Fairy' 'Psychic' 'Psychic' 'Electric' 'Electric'\n",
" 'Electric' 'Electric' 'Grass' 'Water' 'Water' 'Rock' 'Water' 'Grass'\n",
" 'Grass' 'Grass' 'Normal' 'Grass' 'Grass' 'Bug' 'Water' 'Water' 'Psychic'\n",
" 'Dark' 'Dark' 'Water' 'Ghost' 'Psychic' 'Psychic' 'Normal' 'Bug' 'Bug'\n",
" 'Normal' 'Ground' 'Steel' 'Steel' 'Fairy' 'Fairy' 'Water' 'Bug' 'Bug'\n",
" 'Bug' 'Bug' 'Bug' 'Dark' 'Normal' 'Normal' 'Fire' 'Fire' 'Ice' 'Ice'\n",
" 'Water' 'Water' 'Water' 'Ice' 'Water' 'Steel' 'Dark' 'Dark' 'Dark'\n",
" 'Water' 'Ground' 'Ground' 'Normal' 'Normal' 'Normal' 'Fighting'\n",
" 'Fighting' 'Ice' 'Electric' 'Fire' 'Normal' 'Normal' 'Electric' 'Fire'\n",
" 'Water' 'Rock' 'Rock' 'Rock' 'Rock' 'Psychic' 'Fire' 'Psychic' 'Grass'\n",
" 'Grass' 'Grass' 'Grass' 'Fire' 'Fire' 'Fire' 'Fire' 'Water' 'Water'\n",
" 'Water' 'Water' 'Dark' 'Dark' 'Normal' 'Normal' 'Bug' 'Bug' 'Bug' 'Bug'\n",
" 'Bug' 'Water' 'Water' 'Water' 'Grass' 'Grass' 'Grass' 'Normal' 'Normal'\n",
" 'Water' 'Water' 'Psychic' 'Psychic' 'Psychic' 'Psychic' 'Bug' 'Bug'\n",
" 'Grass' 'Grass' 'Normal' 'Normal' 'Normal' 'Bug' 'Bug' 'Bug' 'Normal'\n",
" 'Normal' 'Normal' 'Fighting' 'Fighting' 'Normal' 'Rock' 'Normal' 'Normal'\n",
" 'Dark' 'Dark' 'Steel' 'Steel' 'Steel' 'Steel' 'Steel' 'Steel' 'Fighting'\n",
" 'Fighting' 'Fighting' 'Electric' 'Electric' 'Electric' 'Electric'\n",
" 'Electric' 'Bug' 'Bug' 'Grass' 'Poison' 'Poison' 'Water' 'Water' 'Water'\n",
" 'Water' 'Water' 'Fire' 'Fire' 'Fire' 'Fire' 'Psychic' 'Psychic' 'Normal'\n",
" 'Ground' 'Ground' 'Ground' 'Grass' 'Grass' 'Normal' 'Dragon' 'Dragon'\n",
" 'Normal' 'Poison' 'Rock' 'Rock' 'Water' 'Water' 'Water' 'Water' 'Ground'\n",
" 'Ground' 'Rock' 'Rock' 'Rock' 'Rock' 'Water' 'Water' 'Normal' 'Normal'\n",
" 'Ghost' 'Ghost' 'Ghost' 'Ghost' 'Ghost' 'Grass' 'Psychic' 'Dark' 'Dark'\n",
" 'Psychic' 'Ice' 'Ice' 'Ice' 'Ice' 'Ice' 'Ice' 'Water' 'Water' 'Water'\n",
" 'Water' 'Water' 'Dragon' 'Dragon' 'Dragon' 'Dragon' 'Steel' 'Steel'\n",
" 'Steel' 'Steel' 'Rock' 'Ice' 'Steel' 'Dragon' 'Dragon' 'Dragon' 'Dragon'\n",
" 'Water' 'Water' 'Ground' 'Ground' 'Dragon' 'Dragon' 'Steel' 'Psychic'\n",
" 'Psychic' 'Psychic' 'Psychic' 'Grass' 'Grass' 'Grass' 'Fire' 'Fire'\n",
" 'Fire' 'Water' 'Water' 'Water' 'Normal' 'Normal' 'Normal' 'Normal'\n",
" 'Normal' 'Bug' 'Bug' 'Electric' 'Electric' 'Electric' 'Grass' 'Grass'\n",
" 'Rock' 'Rock' 'Rock' 'Rock' 'Bug' 'Bug' 'Bug' 'Bug' 'Bug' 'Bug' 'Bug'\n",
" 'Electric' 'Water' 'Water' 'Grass' 'Grass' 'Water' 'Water' 'Normal'\n",
" 'Ghost' 'Ghost' 'Normal' 'Normal' 'Normal' 'Ghost' 'Dark' 'Normal'\n",
" 'Normal' 'Psychic' 'Poison' 'Poison' 'Steel' 'Steel' 'Rock' 'Psychic'\n",
" 'Normal' 'Normal' 'Ghost' 'Dragon' 'Dragon' 'Dragon' 'Dragon' 'Normal'\n",
" 'Fighting' 'Fighting' 'Fighting' 'Ground' 'Ground' 'Poison' 'Poison'\n",
" 'Poison' 'Poison' 'Grass' 'Water' 'Water' 'Water' 'Grass' 'Grass' 'Grass'\n",
" 'Dark' 'Electric' 'Normal' 'Ground' 'Grass' 'Electric' 'Fire' 'Fairy'\n",
" 'Bug' 'Grass' 'Ice' 'Ground' 'Ice' 'Normal' 'Psychic' 'Psychic' 'Rock'\n",
" 'Ghost' 'Ice' 'Electric' 'Electric' 'Electric' 'Electric' 'Electric'\n",
" 'Electric' 'Psychic' 'Psychic' 'Psychic' 'Steel' 'Water' 'Fire' 'Normal'\n",
" 'Ghost' 'Ghost' 'Psychic' 'Water' 'Water' 'Dark' 'Grass' 'Grass' 'Normal'\n",
" 'Psychic' 'Grass' 'Grass' 'Grass' 'Fire' 'Fire' 'Fire' 'Water' 'Water'\n",
" 'Water' 'Normal' 'Normal' 'Normal' 'Normal' 'Normal' 'Dark' 'Dark'\n",
" 'Grass' 'Grass' 'Fire' 'Fire' 'Water' 'Water' 'Psychic' 'Psychic'\n",
" 'Normal' 'Normal' 'Normal' 'Electric' 'Electric' 'Rock' 'Rock' 'Rock'\n",
" 'Psychic' 'Psychic' 'Ground' 'Ground' 'Normal' 'Normal' 'Fighting'\n",
" 'Fighting' 'Fighting' 'Water' 'Water' 'Water' 'Fighting' 'Fighting' 'Bug'\n",
" 'Bug' 'Bug' 'Bug' 'Bug' 'Bug' 'Grass' 'Grass' 'Grass' 'Grass' 'Water'\n",
" 'Ground' 'Ground' 'Ground' 'Fire' 'Fire' 'Fire' 'Grass' 'Bug' 'Bug'\n",
" 'Dark' 'Dark' 'Psychic' 'Ghost' 'Ghost' 'Water' 'Water' 'Rock' 'Rock'\n",
" 'Poison' 'Poison' 'Dark' 'Dark' 'Normal' 'Normal' 'Psychic' 'Psychic'\n",
" 'Psychic' 'Psychic' 'Psychic' 'Psychic' 'Water' 'Water' 'Ice' 'Ice' 'Ice'\n",
" 'Normal' 'Normal' 'Electric' 'Bug' 'Bug' 'Grass' 'Grass' 'Water' 'Water'\n",
" 'Water' 'Bug' 'Bug' 'Grass' 'Grass' 'Steel' 'Steel' 'Steel' 'Electric'\n",
" 'Electric' 'Electric' 'Psychic' 'Psychic' 'Ghost' 'Ghost' 'Ghost'\n",
" 'Dragon' 'Dragon' 'Dragon' 'Ice' 'Ice' 'Ice' 'Bug' 'Bug' 'Ground'\n",
" 'Fighting' 'Fighting' 'Dragon' 'Ground' 'Ground' 'Dark' 'Dark' 'Normal'\n",
" 'Normal' 'Normal' 'Dark' 'Dark' 'Fire' 'Bug' 'Dark' 'Dark' 'Dark' 'Bug'\n",
" 'Bug' 'Steel' 'Rock' 'Grass' 'Flying' 'Flying' 'Electric' 'Electric'\n",
" 'Dragon' 'Dragon' 'Ground' 'Ground' 'Dragon' 'Dragon' 'Dragon' 'Water'\n",
" 'Water' 'Normal' 'Normal' 'Bug' 'Grass' 'Grass' 'Grass' 'Fire' 'Fire'\n",
" 'Fire' 'Water' 'Water' 'Water' 'Normal' 'Normal' 'Normal' 'Fire' 'Fire'\n",
" 'Bug' 'Bug' 'Bug' 'Fire' 'Fire' 'Fairy' 'Fairy' 'Fairy' 'Grass' 'Grass'\n",
" 'Fighting' 'Fighting' 'Normal' 'Psychic' 'Psychic' 'Psychic' 'Steel'\n",
" 'Steel' 'Steel' 'Steel' 'Fairy' 'Fairy' 'Fairy' 'Fairy' 'Dark' 'Dark'\n",
" 'Rock' 'Rock' 'Poison' 'Poison' 'Water' 'Water' 'Electric' 'Electric'\n",
" 'Rock' 'Rock' 'Rock' 'Rock' 'Fairy' 'Fighting' 'Electric' 'Rock' 'Dragon'\n",
" 'Dragon' 'Dragon' 'Steel' 'Ghost' 'Ghost' 'Ghost' 'Ghost' 'Ghost' 'Ghost'\n",
" 'Ghost' 'Ghost' 'Ghost' 'Ghost' 'Ice' 'Ice' 'Flying' 'Flying' 'Fairy'\n",
" 'Dark' 'Dragon' 'Rock' 'Rock' 'Psychic' 'Psychic' 'Fire']\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Hk0OuZbTvrAN",
"outputId": "8c3f8679-3e54-47fa-b30c-585b60d11f93"
},
"source": [
"print(pokemon[0])\n",
"print(pokemon['Bulbasaur'])\n",
"print()\n",
"print(pokemon['Bulbasaur':'Venusaur'])"
],
"execution_count": 65,
"outputs": [
{
"output_type": "stream",
"text": [
"Grass\n",
"Grass\n",
"\n",
"Name\n",
"Bulbasaur Grass\n",
"Ivysaur Grass\n",
"Venusaur Grass\n",
"Name: Type 1, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "X9o4DgKlyhui"
},
"source": [
"#### Missing indexes"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "AlM7aHzfxsr1",
"outputId": "c7f809b4-bbd7-49df-dcbf-a842f656d1fd"
},
"source": [
"# This will error out\n",
"# print(pokemon['Pikachu', 'Digimon'])\n",
"\n",
"# But this will simply add a new index with no value\n",
"print(pokemon.reindex(index = ['Pikachu', 'Digimon']))"
],
"execution_count": 67,
"outputs": [
{
"output_type": "stream",
"text": [
"Name\n",
"Pikachu Electric\n",
"Digimon NaN\n",
"Name: Type 1, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "QsaNU7Tmy42M"
},
"source": [
"#### Using method to get values"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "_kw_y3k6ytdl",
"outputId": "36d85bf6-acc8-4315-df5a-46c9ac0cef7d"
},
"source": [
"print(pokemon.get(0))\n",
"print(pokemon.get('Charizard'))\n",
"print()\n",
"print(pokemon.get(['Bulbasaur', 'Pikachu']))\n",
"print()\n",
"\n",
"# Fill missing values\n",
"print(pokemon.get(key = ['Charizard', 'Meowth', 'Digimon'], default = 'This is not a pokemon'))"
],
"execution_count": 72,
"outputs": [
{
"output_type": "stream",
"text": [
"Grass\n",
"Fire\n",
"\n",
"Name\n",
"Bulbasaur Grass\n",
"Pikachu Electric\n",
"Name: Type 1, dtype: object\n",
"\n",
"This is not a pokemon\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "le7ebtnRzyWR"
},
"source": [
"#### Math Methods"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "5qDHzHfVzK-h",
"outputId": "8a507351-4474-45df-985d-86d2881abdf9"
},
"source": [
"python_list = range(1, 101)\n",
"s = pd.Series(python_list)\n",
"print(s.count())\n",
"print(s.sum())\n",
"print(s.mean())\n",
"print(s.std())\n",
"print(s.min())\n",
"print(s.max())\n",
"print(s.median())\n",
"# print(s.mode())\n",
"print()\n",
"print(s.describe())"
],
"execution_count": 78,
"outputs": [
{
"output_type": "stream",
"text": [
"100\n",
"5050\n",
"50.5\n",
"29.011491975882016\n",
"1\n",
"100\n",
"50.5\n",
"\n",
"count 100.000000\n",
"mean 50.500000\n",
"std 29.011492\n",
"min 1.000000\n",
"25% 25.750000\n",
"50% 50.500000\n",
"75% 75.250000\n",
"max 100.000000\n",
"dtype: float64\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "g8VVyS8t1FSr"
},
"source": [
"#### Find index of largest and smallest numbers"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "_LhZPdAV0ijV",
"outputId": "5f5b1bc7-539a-483e-c272-84767cb00240"
},
"source": [
"print(s.idxmax())\n",
"print(s.idxmin())"
],
"execution_count": 79,
"outputs": [
{
"output_type": "stream",
"text": [
"99\n",
"0\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "iDwbUATJ1jBI"
},
"source": [
"#### Value_counts"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "lrKu2SIf1X46",
"outputId": "2952b028-f4f7-480a-b3a1-f54248269f75"
},
"source": [
"print(pokemon.value_counts().head())\n",
"print()\n",
"print(pokemon.value_counts(ascending = True).head())"
],
"execution_count": 84,
"outputs": [
{
"output_type": "stream",
"text": [
"Water 112\n",
"Normal 98\n",
"Grass 70\n",
"Bug 69\n",
"Psychic 57\n",
"Name: Type 1, dtype: int64\n",
"\n",
"Flying 4\n",
"Fairy 17\n",
"Ice 24\n",
"Steel 27\n",
"Fighting 27\n",
"Name: Type 1, dtype: int64\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-2B5FBwD2Vag"
},
"source": [
"#### Apply function on every Series values"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "DbWJv-Pa1mKk",
"outputId": "b8b9c6fd-1869-41e2-bf1e-1970fd9d0b9b"
},
"source": [
"def change_grass_to_leaf(p):\n",
" if p == 'Grass':\n",
" return 'Leaf'\n",
" else:\n",
" return p\n",
"\n",
"print(pokemon.apply(change_grass_to_leaf).head(8))"
],
"execution_count": 87,
"outputs": [
{
"output_type": "stream",
"text": [
"Name\n",
"Bulbasaur Leaf\n",
"Ivysaur Leaf\n",
"Venusaur Leaf\n",
"VenusaurMega Venusaur Leaf\n",
"Charmander Fire\n",
"Charmeleon Fire\n",
"Charizard Fire\n",
"CharizardMega Charizard X Fire\n",
"Name: Type 1, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "DIMrgTWx3SAu"
},
"source": [
"#### Apply Lambda methods"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "P_ziQWAC3GkL",
"outputId": "7e31b56e-1754-4d12-bc2f-76f055ac308c"
},
"source": [
"print(pokemon.apply(lambda p: 'Leaf' if p == 'Grass' else p).head(8))"
],
"execution_count": 88,
"outputs": [
{
"output_type": "stream",
"text": [
"Name\n",
"Bulbasaur Leaf\n",
"Ivysaur Leaf\n",
"Venusaur Leaf\n",
"VenusaurMega Venusaur Leaf\n",
"Charmander Fire\n",
"Charmeleon Fire\n",
"Charizard Fire\n",
"CharizardMega Charizard X Fire\n",
"Name: Type 1, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "HYesIqzR482Y"
},
"source": [
"#### Mapping value of a Series with index of another Series"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "aJqsix_T3oxg",
"outputId": "e3d28fd6-0a9a-4f33-8e1c-2703227dfe86"
},
"source": [
"pokemon_names = pd.read_csv(pokemon_csv_url, usecols = ['Name'], squeeze = True)\n",
"print(pokemon_names.head(3))\n",
"print()\n",
"pokemon_types = pd.read_csv(pokemon_csv_url, index_col = 'Name', usecols = ['Name', 'Type 1'], squeeze = True)\n",
"print(pokemon_types.head(3))\n",
"print()\n",
"print(pokemon_names.map(pokemon_types).head(8))"
],
"execution_count": 94,
"outputs": [
{
"output_type": "stream",
"text": [
"0 Bulbasaur\n",
"1 Ivysaur\n",
"2 Venusaur\n",
"Name: Name, dtype: object\n",
"\n",
"Name\n",
"Bulbasaur Grass\n",
"Ivysaur Grass\n",
"Venusaur Grass\n",
"Name: Type 1, dtype: object\n",
"\n",
"0 Grass\n",
"1 Grass\n",
"2 Grass\n",
"3 Grass\n",
"4 Fire\n",
"5 Fire\n",
"6 Fire\n",
"7 Fire\n",
"Name: Name, dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "VvvIYj1l5MIr"
},
"source": [
""
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "B_IhIw5P6OZ-"
},
"source": [
"### DataFrames"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "zQTBWxKy6SdZ"
},
"source": [
"#### Shared methods between Series and DataFrames"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "P09qdfC86Pos",
"outputId": "3a7f9c54-e88d-4527-ff3d-d30e4e5cdb38"
},
"source": [
"pokemon = pd.read_csv(pokemon_csv_url)\n",
"print(pokemon.head())\n",
"print()\n",
"print(pokemon.tail())"
],
"execution_count": 100,
"outputs": [
{
"output_type": "stream",
"text": [
" # Name Type 1 ... Speed Generation Legendary\n",
"0 1 Bulbasaur Grass ... 45 1 False\n",
"1 2 Ivysaur Grass ... 60 1 False\n",
"2 3 Venusaur Grass ... 80 1 False\n",
"3 3 VenusaurMega Venusaur Grass ... 80 1 False\n",
"4 4 Charmander Fire ... 65 1 False\n",
"\n",
"[5 rows x 13 columns]\n",
"\n",
" # Name Type 1 ... Speed Generation Legendary\n",
"795 719 Diancie Rock ... 50 6 True\n",
"796 719 DiancieMega Diancie Rock ... 110 6 True\n",
"797 720 HoopaHoopa Confined Psychic ... 70 6 True\n",
"798 720 HoopaHoopa Unbound Psychic ... 80 6 True\n",
"799 721 Volcanion Fire ... 70 6 True\n",
"\n",
"[5 rows x 13 columns]\n",
"\n",
"RangeIndex(start=0, stop=800, step=1)\n",
"\n",
"[[1 'Bulbasaur' 'Grass' ... 45 1 False]\n",
" [2 'Ivysaur' 'Grass' ... 60 1 False]\n",
" [3 'Venusaur' 'Grass' ... 80 1 False]\n",
" ...\n",
" [720 'HoopaHoopa Confined' 'Psychic' ... 70 6 True]\n",
" [720 'HoopaHoopa Unbound' 'Psychic' ... 80 6 True]\n",
" [721 'Volcanion' 'Fire' ... 70 6 True]]\n",
"\n",
"(800, 13)\n",
"\n",
"# int64\n",
"Name object\n",
"Type 1 object\n",
"Type 2 object\n",
"Total int64\n",
"HP int64\n",
"Attack int64\n",
"Defense int64\n",
"Sp. Atk int64\n",
"Sp. Def int64\n",
"Speed int64\n",
"Generation int64\n",
"Legendary bool\n",
"dtype: object\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "cHFz80E67vxP",
"outputId": "ac1428b8-ee86-45ab-e2b7-09dae2c47df2"
},
"source": [
"print(pokemon.index)\n",
"print()\n",
"print(pokemon.values)"
],
"execution_count": 108,
"outputs": [
{
"output_type": "stream",
"text": [
"RangeIndex(start=0, stop=800, step=1)\n",
"\n",
"[[1 'Bulbasaur' 'Grass' ... 45 1 False]\n",
" [2 'Ivysaur' 'Grass' ... 60 1 False]\n",
" [3 'Venusaur' 'Grass' ... 80 1 False]\n",
" ...\n",
" [720 'HoopaHoopa Confined' 'Psychic' ... 70 6 True]\n",
" [720 'HoopaHoopa Unbound' 'Psychic' ... 80 6 True]\n",
" [721 'Volcanion' 'Fire' ... 70 6 True]]\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "lYjCjENr7JhF",
"outputId": "62adae20-fc69-4f14-995a-8f7338d55a00"
},
"source": [
"print(pokemon.shape)\n",
"print()\n",
"print(pokemon.dtypes)\n",
"print()\n",
"print(pokemon.columns)"
],
"execution_count": 105,
"outputs": [
{
"output_type": "stream",
"text": [
"(800, 13)\n",
"\n",
"# int64\n",
"Name object\n",
"Type 1 object\n",
"Type 2 object\n",
"Total int64\n",
"HP int64\n",
"Attack int64\n",
"Defense int64\n",
"Sp. Atk int64\n",
"Sp. Def int64\n",
"Speed int64\n",
"Generation int64\n",
"Legendary bool\n",
"dtype: object\n",
"\n",
"Index(['#', 'Name', 'Type 1', 'Type 2', 'Total', 'HP', 'Attack', 'Defense',\n",
" 'Sp. Atk', 'Sp. Def', 'Speed', 'Generation', 'Legendary'],\n",
" dtype='object')\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "XxdVlo767owy",
"outputId": "30b5b510-f526-4203-ba4c-8e14358c584c"
},
"source": [
"print(pokemon.axes)"
],
"execution_count": 106,
"outputs": [
{
"output_type": "stream",
"text": [
"[RangeIndex(start=0, stop=800, step=1), Index(['#', 'Name', 'Type 1', 'Type 2', 'Total', 'HP', 'Attack', 'Defense',\n",
" 'Sp. Atk', 'Sp. Def', 'Speed', 'Generation', 'Legendary'],\n",
" dtype='object')]\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "faaS-Z4H7lO8",
"outputId": "4c8138c1-582b-4e44-e124-4fb89e26b94a"
},
"source": [
"print(pokemon.info)"
],
"execution_count": 107,
"outputs": [
{
"output_type": "stream",
"text": [
"<bound method DataFrame.info of # Name Type 1 ... Speed Generation Legendary\n",
"0 1 Bulbasaur Grass ... 45 1 False\n",
"1 2 Ivysaur Grass ... 60 1 False\n",
"2 3 Venusaur Grass ... 80 1 False\n",
"3 3 VenusaurMega Venusaur Grass ... 80 1 False\n",
"4 4 Charmander Fire ... 65 1 False\n",
".. ... ... ... ... ... ... ...\n",
"795 719 Diancie Rock ... 50 6 True\n",
"796 719 DiancieMega Diancie Rock ... 110 6 True\n",
"797 720 HoopaHoopa Confined Psychic ... 70 6 True\n",
"798 720 HoopaHoopa Unbound Psychic ... 80 6 True\n",
"799 721 Volcanion Fire ... 70 6 True\n",
"\n",
"[800 rows x 13 columns]>\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "PrT1zdH-8Isg"
},
"source": [
"#### Selecting a column in DataFrames"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "VSnHFfRG6qIM",
"outputId": "ad0a7ab4-c40d-4ce2-f95f-e2a767fe5323"
},
"source": [
"print(pokemon.Name.head())\n",
"print()\n",
"print(pokemon['Name'].head())\n",
"print()\n",
"print(type(pokemon['Name']))"
],
"execution_count": 112,
"outputs": [
{
"output_type": "stream",
"text": [
"0 Bulbasaur\n",
"1 Ivysaur\n",
"2 Venusaur\n",
"3 VenusaurMega Venusaur\n",
"4 Charmander\n",
"Name: Name, dtype: object\n",
"\n",
"0 Bulbasaur\n",
"1 Ivysaur\n",
"2 Venusaur\n",
"3 VenusaurMega Venusaur\n",
"4 Charmander\n",
"Name: Name, dtype: object\n",
"\n",
"<class 'pandas.core.series.Series'>\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ena7FpL_8qV1"
},
"source": [
"#### Selecting multiple columns in DataFrames"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "kRZsW1j18Mh7",
"outputId": "c4a6735a-c0af-452e-ff5c-6327f5286450"
},
"source": [
"print(pokemon[['Name', 'Type 1', 'HP']].head())"
],
"execution_count": 116,
"outputs": [
{
"output_type": "stream",
"text": [
" Name Type 1 HP\n",
"0 Bulbasaur Grass 45\n",
"1 Ivysaur Grass 60\n",
"2 Venusaur Grass 80\n",
"3 VenusaurMega Venusaur Grass 80\n",
"4 Charmander Fire 39\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "z0F1Cyu99XH3"
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "CWM8DTKs9XYK"
},
"source": [
"#### Adding or updating a column with single value"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "9fpABILf8wIZ",
"outputId": "8ae80590-0183-4a38-ca9d-da7a63013002"
},
"source": [
"pokemon['Universe'] = 'Pokemon'\n",
"print(pokemon)"
],
"execution_count": 119,
"outputs": [
{
"output_type": "stream",
"text": [
" # Name Type 1 ... Generation Legendary Universe\n",
"0 1 Bulbasaur Grass ... 1 False Pokemon\n",
"1 2 Ivysaur Grass ... 1 False Pokemon\n",
"2 3 Venusaur Grass ... 1 False Pokemon\n",
"3 3 VenusaurMega Venusaur Grass ... 1 False Pokemon\n",
"4 4 Charmander Fire ... 1 False Pokemon\n",
".. ... ... ... ... ... ... ...\n",
"795 719 Diancie Rock ... 6 True Pokemon\n",
"796 719 DiancieMega Diancie Rock ... 6 True Pokemon\n",
"797 720 HoopaHoopa Confined Psychic ... 6 True Pokemon\n",
"798 720 HoopaHoopa Unbound Psychic ... 6 True Pokemon\n",
"799 721 Volcanion Fire ... 6 True Pokemon\n",
"\n",
"[800 rows x 14 columns]\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "H8zlvzy59s0C",
"outputId": "7bfbd4c4-4837-4c01-b1aa-0f6092f511f4"
},
"source": [
"pokemon.insert(12, column = 'Channel', value = 'Cartoon Network')\n",
"print(pokemon)"
],
"execution_count": 129,
"outputs": [
{
"output_type": "stream",
"text": [
" # Name Type 1 ... Channel Legendary Universe\n",
"0 1 Bulbasaur Grass ... Cartoon Network False Pokemon\n",
"1 2 Ivysaur Grass ... Cartoon Network False Pokemon\n",
"2 3 Venusaur Grass ... Cartoon Network False Pokemon\n",
"3 3 VenusaurMega Venusaur Grass ... Cartoon Network False Pokemon\n",
"4 4 Charmander Fire ... Cartoon Network False Pokemon\n",
".. ... ... ... ... ... ... ...\n",
"795 719 Diancie Rock ... Cartoon Network True Pokemon\n",
"796 719 DiancieMega Diancie Rock ... Cartoon Network True Pokemon\n",
"797 720 HoopaHoopa Confined Psychic ... Cartoon Network True Pokemon\n",
"798 720 HoopaHoopa Unbound Psychic ... Cartoon Network True Pokemon\n",
"799 721 Volcanion Fire ... Cartoon Network True Pokemon\n",
"\n",
"[800 rows x 15 columns]\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Nfw0NPEf-zXz"
},
"source": [
"#### Math operations on columns"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "BB0C4l1s9M-C",
"outputId": "2e54a5e7-1d6d-4915-b41c-e5f6380553f7"
},
"source": [
"print(pokemon['HP'].head())\n",
"print()\n",
"print(pokemon['HP'].add(100).head())\n",
"print()\n",
"print((pokemon['HP'] + 1000).head())"
],
"execution_count": 133,
"outputs": [
{
"output_type": "stream",
"text": [
"0 45\n",
"1 60\n",
"2 80\n",
"3 80\n",
"4 39\n",
"Name: HP, dtype: int64\n",
"\n",
"0 145\n",
"1 160\n",
"2 180\n",
"3 180\n",
"4 139\n",
"Name: HP, dtype: int64\n",
"\n",
"0 1045\n",
"1 1060\n",
"2 1080\n",
"3 1080\n",
"4 1039\n",
"Name: HP, dtype: int64\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "ca43OaET-1cd",
"outputId": "b22dd5b0-1372-4e0e-8dff-4b4fac281792"
},
"source": [
"print(pokemon['HP'].sub(2).head())\n",
"print()\n",
"print(pokemon['HP'].mul(10).head())\n",
"print()\n",
"print(pokemon['HP'].div(5).head())"
],
"execution_count": 135,
"outputs": [
{
"output_type": "stream",
"text": [
"0 43\n",
"1 58\n",
"2 78\n",
"3 78\n",
"4 37\n",
"Name: HP, dtype: int64\n",
"\n",
"0 450\n",
"1 600\n",
"2 800\n",
"3 800\n",
"4 390\n",
"Name: HP, dtype: int64\n",
"\n",
"0 9.0\n",
"1 12.0\n",
"2 16.0\n",
"3 16.0\n",
"4 7.8\n",
"Name: HP, dtype: float64\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "A4fMPKMm_lp0"
},
"source": [
"#### Drop rows with na values"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 203
},
"id": "irlT3X3J-hxA",
"outputId": "91c97a6f-c5d2-4c75-cc52-e7467fe30554"
},
"source": [
"# Drop rows with value na in any of the column\n",
"pokemon.dropna(how = 'all').head()\n",
"\n",
"# Drop rows with value na in a specific column(s)\n",
"pokemon.dropna(subset = ['Type 1', 'Type 2']).head()"
],
"execution_count": 146,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>#</th>\n",
" <th>Name</th>\n",
" <th>Type 1</th>\n",
" <th>Type 2</th>\n",
" <th>Total</th>\n",
" <th>HP</th>\n",
" <th>Attack</th>\n",
" <th>Defense</th>\n",
" <th>Sp. Atk</th>\n",
" <th>Sp. Def</th>\n",
" <th>Speed</th>\n",
" <th>Generation</th>\n",
" <th>Channel</th>\n",
" <th>Legendary</th>\n",
" <th>Universe</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>Bulbasaur</td>\n",
" <td>Grass</td>\n",
" <td>Poison</td>\n",
" <td>318</td>\n",
" <td>45</td>\n",
" <td>49</td>\n",
" <td>49</td>\n",
" <td>65</td>\n",
" <td>65</td>\n",
" <td>45</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>Ivysaur</td>\n",
" <td>Grass</td>\n",
" <td>Poison</td>\n",
" <td>405</td>\n",
" <td>60</td>\n",
" <td>62</td>\n",
" <td>63</td>\n",
" <td>80</td>\n",
" <td>80</td>\n",
" <td>60</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>Venusaur</td>\n",
" <td>Grass</td>\n",
" <td>Poison</td>\n",
" <td>525</td>\n",
" <td>80</td>\n",
" <td>82</td>\n",
" <td>83</td>\n",
" <td>100</td>\n",
" <td>100</td>\n",
" <td>80</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3</td>\n",
" <td>VenusaurMega Venusaur</td>\n",
" <td>Grass</td>\n",
" <td>Poison</td>\n",
" <td>625</td>\n",
" <td>80</td>\n",
" <td>100</td>\n",
" <td>123</td>\n",
" <td>122</td>\n",
" <td>120</td>\n",
" <td>80</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>6</td>\n",
" <td>Charizard</td>\n",
" <td>Fire</td>\n",
" <td>Flying</td>\n",
" <td>534</td>\n",
" <td>78</td>\n",
" <td>84</td>\n",
" <td>78</td>\n",
" <td>109</td>\n",
" <td>85</td>\n",
" <td>100</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" # Name Type 1 ... Channel Legendary Universe\n",
"0 1 Bulbasaur Grass ... Cartoon Network False Pokemon\n",
"1 2 Ivysaur Grass ... Cartoon Network False Pokemon\n",
"2 3 Venusaur Grass ... Cartoon Network False Pokemon\n",
"3 3 VenusaurMega Venusaur Grass ... Cartoon Network False Pokemon\n",
"6 6 Charizard Fire ... Cartoon Network False Pokemon\n",
"\n",
"[5 rows x 15 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 146
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "WA4T5qAHAGlj"
},
"source": [
"Drop columns with na values"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 203
},
"id": "2RzPibpA_u6s",
"outputId": "daba0ed3-3336-4644-8b6f-8fb068950ada"
},
"source": [
"pokemon.dropna(axis = 1).head()\n",
"pokemon.dropna(axis = 'columns').head()"
],
"execution_count": 147,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>#</th>\n",
" <th>Name</th>\n",
" <th>Type 1</th>\n",
" <th>Total</th>\n",
" <th>HP</th>\n",
" <th>Attack</th>\n",
" <th>Defense</th>\n",
" <th>Sp. Atk</th>\n",
" <th>Sp. Def</th>\n",
" <th>Speed</th>\n",
" <th>Generation</th>\n",
" <th>Channel</th>\n",
" <th>Legendary</th>\n",
" <th>Universe</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>Bulbasaur</td>\n",
" <td>Grass</td>\n",
" <td>318</td>\n",
" <td>45</td>\n",
" <td>49</td>\n",
" <td>49</td>\n",
" <td>65</td>\n",
" <td>65</td>\n",
" <td>45</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>Ivysaur</td>\n",
" <td>Grass</td>\n",
" <td>405</td>\n",
" <td>60</td>\n",
" <td>62</td>\n",
" <td>63</td>\n",
" <td>80</td>\n",
" <td>80</td>\n",
" <td>60</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>Venusaur</td>\n",
" <td>Grass</td>\n",
" <td>525</td>\n",
" <td>80</td>\n",
" <td>82</td>\n",
" <td>83</td>\n",
" <td>100</td>\n",
" <td>100</td>\n",
" <td>80</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3</td>\n",
" <td>VenusaurMega Venusaur</td>\n",
" <td>Grass</td>\n",
" <td>625</td>\n",
" <td>80</td>\n",
" <td>100</td>\n",
" <td>123</td>\n",
" <td>122</td>\n",
" <td>120</td>\n",
" <td>80</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4</td>\n",
" <td>Charmander</td>\n",
" <td>Fire</td>\n",
" <td>309</td>\n",
" <td>39</td>\n",
" <td>52</td>\n",
" <td>43</td>\n",
" <td>60</td>\n",
" <td>50</td>\n",
" <td>65</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" # Name Type 1 ... Channel Legendary Universe\n",
"0 1 Bulbasaur Grass ... Cartoon Network False Pokemon\n",
"1 2 Ivysaur Grass ... Cartoon Network False Pokemon\n",
"2 3 Venusaur Grass ... Cartoon Network False Pokemon\n",
"3 3 VenusaurMega Venusaur Grass ... Cartoon Network False Pokemon\n",
"4 4 Charmander Fire ... Cartoon Network False Pokemon\n",
"\n",
"[5 rows x 14 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 147
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "1rqz_07xA_sm"
},
"source": [
"#### Fill na values"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "PtrxtPyqAVJ-",
"outputId": "a579ab27-ac74-49dc-c972-0a246bffc10b"
},
"source": [
"# Fill na values with 0\n",
"pokemon.fillna(0)\n",
"\n",
"pokemon['Type 2'].fillna('Normal').head()"
],
"execution_count": 149,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"0 Poison\n",
"1 Poison\n",
"2 Poison\n",
"3 Poison\n",
"4 Normal\n",
"Name: Type 2, dtype: object"
]
},
"metadata": {
"tags": []
},
"execution_count": 149
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3jzI9J1BBumP"
},
"source": [
"#### Convert column type"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "S91v8PuJBNxi",
"outputId": "b7c71551-cb39-44e6-e0db-472d7798e39f"
},
"source": [
"pokemon['HP'].astype('float')"
],
"execution_count": 151,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"0 45.0\n",
"1 60.0\n",
"2 80.0\n",
"3 80.0\n",
"4 39.0\n",
" ... \n",
"795 50.0\n",
"796 50.0\n",
"797 80.0\n",
"798 80.0\n",
"799 80.0\n",
"Name: HP, Length: 800, dtype: float64"
]
},
"metadata": {
"tags": []
},
"execution_count": 151
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "4fFF--UVCSdR"
},
"source": [
"#### Change type to category if possible values are limited"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "g-ubz83ACWxi",
"outputId": "3a3a9f6f-2e4d-40e4-e69e-bb9b781808a2"
},
"source": [
"pokemon['Type 1'].astype('category')"
],
"execution_count": 155,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"0 Grass\n",
"1 Grass\n",
"2 Grass\n",
"3 Grass\n",
"4 Fire\n",
" ... \n",
"795 Rock\n",
"796 Rock\n",
"797 Psychic\n",
"798 Psychic\n",
"799 Fire\n",
"Name: Type 1, Length: 800, dtype: category\n",
"Categories (18, object): ['Bug', 'Dark', 'Dragon', 'Electric', ..., 'Psychic', 'Rock', 'Steel',\n",
" 'Water']"
]
},
"metadata": {
"tags": []
},
"execution_count": 155
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "qUFGLsAnB8yH"
},
"source": [
"#### Count unique values in a column"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "6HdrQoUNBz7g",
"outputId": "d0d01e5a-190a-4247-fe1c-5cfd68f75678"
},
"source": [
"pokemon['Type 1'].nunique()"
],
"execution_count": 153,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"18"
]
},
"metadata": {
"tags": []
},
"execution_count": 153
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "1GQSG2M0CoUk"
},
"source": [
"#### Sort values"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 203
},
"id": "0vMXwlmOCApG",
"outputId": "8811b3a7-8c32-4bb5-feac-87a8c04911cd"
},
"source": [
"pokemon.sort_values('Name')\n",
"pokemon.sort_values('Name', ascending = False).head()"
],
"execution_count": 159,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>#</th>\n",
" <th>Name</th>\n",
" <th>Type 1</th>\n",
" <th>Type 2</th>\n",
" <th>Total</th>\n",
" <th>HP</th>\n",
" <th>Attack</th>\n",
" <th>Defense</th>\n",
" <th>Sp. Atk</th>\n",
" <th>Sp. Def</th>\n",
" <th>Speed</th>\n",
" <th>Generation</th>\n",
" <th>Channel</th>\n",
" <th>Legendary</th>\n",
" <th>Universe</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>794</th>\n",
" <td>718</td>\n",
" <td>Zygarde50% Forme</td>\n",
" <td>Dragon</td>\n",
" <td>Ground</td>\n",
" <td>600</td>\n",
" <td>108</td>\n",
" <td>100</td>\n",
" <td>121</td>\n",
" <td>81</td>\n",
" <td>95</td>\n",
" <td>95</td>\n",
" <td>6</td>\n",
" <td>Cartoon Network</td>\n",
" <td>True</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>695</th>\n",
" <td>634</td>\n",
" <td>Zweilous</td>\n",
" <td>Dark</td>\n",
" <td>Dragon</td>\n",
" <td>420</td>\n",
" <td>72</td>\n",
" <td>85</td>\n",
" <td>70</td>\n",
" <td>65</td>\n",
" <td>70</td>\n",
" <td>58</td>\n",
" <td>5</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>46</th>\n",
" <td>41</td>\n",
" <td>Zubat</td>\n",
" <td>Poison</td>\n",
" <td>Flying</td>\n",
" <td>245</td>\n",
" <td>40</td>\n",
" <td>45</td>\n",
" <td>35</td>\n",
" <td>30</td>\n",
" <td>40</td>\n",
" <td>55</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>631</th>\n",
" <td>570</td>\n",
" <td>Zorua</td>\n",
" <td>Dark</td>\n",
" <td>NaN</td>\n",
" <td>330</td>\n",
" <td>40</td>\n",
" <td>65</td>\n",
" <td>40</td>\n",
" <td>80</td>\n",
" <td>40</td>\n",
" <td>65</td>\n",
" <td>5</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>632</th>\n",
" <td>571</td>\n",
" <td>Zoroark</td>\n",
" <td>Dark</td>\n",
" <td>NaN</td>\n",
" <td>510</td>\n",
" <td>60</td>\n",
" <td>105</td>\n",
" <td>60</td>\n",
" <td>120</td>\n",
" <td>60</td>\n",
" <td>105</td>\n",
" <td>5</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" # Name Type 1 ... Channel Legendary Universe\n",
"794 718 Zygarde50% Forme Dragon ... Cartoon Network True Pokemon\n",
"695 634 Zweilous Dark ... Cartoon Network False Pokemon\n",
"46 41 Zubat Poison ... Cartoon Network False Pokemon\n",
"631 570 Zorua Dark ... Cartoon Network False Pokemon\n",
"632 571 Zoroark Dark ... Cartoon Network False Pokemon\n",
"\n",
"[5 rows x 15 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 159
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 203
},
"id": "mQmn0gV7Cuik",
"outputId": "6281497c-7eac-40c3-ed68-43dcdafc616f"
},
"source": [
"# Sort by multiple columns\n",
"pokemon.sort_values(['Type 1', 'Name']).head()"
],
"execution_count": 162,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>#</th>\n",
" <th>Name</th>\n",
" <th>Type 1</th>\n",
" <th>Type 2</th>\n",
" <th>Total</th>\n",
" <th>HP</th>\n",
" <th>Attack</th>\n",
" <th>Defense</th>\n",
" <th>Sp. Atk</th>\n",
" <th>Sp. Def</th>\n",
" <th>Speed</th>\n",
" <th>Generation</th>\n",
" <th>Channel</th>\n",
" <th>Legendary</th>\n",
" <th>Universe</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>678</th>\n",
" <td>617</td>\n",
" <td>Accelgor</td>\n",
" <td>Bug</td>\n",
" <td>NaN</td>\n",
" <td>495</td>\n",
" <td>80</td>\n",
" <td>70</td>\n",
" <td>40</td>\n",
" <td>100</td>\n",
" <td>60</td>\n",
" <td>145</td>\n",
" <td>5</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>182</th>\n",
" <td>168</td>\n",
" <td>Ariados</td>\n",
" <td>Bug</td>\n",
" <td>Poison</td>\n",
" <td>390</td>\n",
" <td>70</td>\n",
" <td>90</td>\n",
" <td>70</td>\n",
" <td>60</td>\n",
" <td>60</td>\n",
" <td>40</td>\n",
" <td>2</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>290</th>\n",
" <td>267</td>\n",
" <td>Beautifly</td>\n",
" <td>Bug</td>\n",
" <td>Flying</td>\n",
" <td>395</td>\n",
" <td>60</td>\n",
" <td>70</td>\n",
" <td>50</td>\n",
" <td>100</td>\n",
" <td>50</td>\n",
" <td>65</td>\n",
" <td>3</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>15</td>\n",
" <td>Beedrill</td>\n",
" <td>Bug</td>\n",
" <td>Poison</td>\n",
" <td>395</td>\n",
" <td>65</td>\n",
" <td>90</td>\n",
" <td>40</td>\n",
" <td>45</td>\n",
" <td>80</td>\n",
" <td>75</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>15</td>\n",
" <td>BeedrillMega Beedrill</td>\n",
" <td>Bug</td>\n",
" <td>Poison</td>\n",
" <td>495</td>\n",
" <td>65</td>\n",
" <td>150</td>\n",
" <td>40</td>\n",
" <td>15</td>\n",
" <td>80</td>\n",
" <td>145</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" # Name Type 1 ... Channel Legendary Universe\n",
"678 617 Accelgor Bug ... Cartoon Network False Pokemon\n",
"182 168 Ariados Bug ... Cartoon Network False Pokemon\n",
"290 267 Beautifly Bug ... Cartoon Network False Pokemon\n",
"18 15 Beedrill Bug ... Cartoon Network False Pokemon\n",
"19 15 BeedrillMega Beedrill Bug ... Cartoon Network False Pokemon\n",
"\n",
"[5 rows x 15 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 162
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 203
},
"id": "NEpLTazQDDAw",
"outputId": "426a7102-66ae-48c7-ef60-9799efbcd63c"
},
"source": [
"# Provide ascending order for multiple columns\n",
"pokemon.sort_values(['Type 1', 'Name'], ascending = [False, True]).head()"
],
"execution_count": 163,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>#</th>\n",
" <th>Name</th>\n",
" <th>Type 1</th>\n",
" <th>Type 2</th>\n",
" <th>Total</th>\n",
" <th>HP</th>\n",
" <th>Attack</th>\n",
" <th>Defense</th>\n",
" <th>Sp. Atk</th>\n",
" <th>Sp. Def</th>\n",
" <th>Speed</th>\n",
" <th>Generation</th>\n",
" <th>Channel</th>\n",
" <th>Legendary</th>\n",
" <th>Universe</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>655</th>\n",
" <td>594</td>\n",
" <td>Alomomola</td>\n",
" <td>Water</td>\n",
" <td>NaN</td>\n",
" <td>470</td>\n",
" <td>165</td>\n",
" <td>75</td>\n",
" <td>80</td>\n",
" <td>40</td>\n",
" <td>45</td>\n",
" <td>65</td>\n",
" <td>5</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>199</th>\n",
" <td>184</td>\n",
" <td>Azumarill</td>\n",
" <td>Water</td>\n",
" <td>Fairy</td>\n",
" <td>420</td>\n",
" <td>100</td>\n",
" <td>50</td>\n",
" <td>80</td>\n",
" <td>60</td>\n",
" <td>80</td>\n",
" <td>50</td>\n",
" <td>2</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>371</th>\n",
" <td>339</td>\n",
" <td>Barboach</td>\n",
" <td>Water</td>\n",
" <td>Ground</td>\n",
" <td>288</td>\n",
" <td>50</td>\n",
" <td>48</td>\n",
" <td>43</td>\n",
" <td>46</td>\n",
" <td>41</td>\n",
" <td>60</td>\n",
" <td>3</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>610</th>\n",
" <td>550</td>\n",
" <td>Basculin</td>\n",
" <td>Water</td>\n",
" <td>NaN</td>\n",
" <td>460</td>\n",
" <td>70</td>\n",
" <td>92</td>\n",
" <td>65</td>\n",
" <td>80</td>\n",
" <td>55</td>\n",
" <td>98</td>\n",
" <td>5</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>9</td>\n",
" <td>Blastoise</td>\n",
" <td>Water</td>\n",
" <td>NaN</td>\n",
" <td>530</td>\n",
" <td>79</td>\n",
" <td>83</td>\n",
" <td>100</td>\n",
" <td>85</td>\n",
" <td>105</td>\n",
" <td>78</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" # Name Type 1 ... Channel Legendary Universe\n",
"655 594 Alomomola Water ... Cartoon Network False Pokemon\n",
"199 184 Azumarill Water ... Cartoon Network False Pokemon\n",
"371 339 Barboach Water ... Cartoon Network False Pokemon\n",
"610 550 Basculin Water ... Cartoon Network False Pokemon\n",
"11 9 Blastoise Water ... Cartoon Network False Pokemon\n",
"\n",
"[5 rows x 15 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 163
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "AMnnMIqoDoEd"
},
"source": [
"#### Sort by index"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 203
},
"id": "EiBINyoMDMnx",
"outputId": "62b6cccd-4cc6-40f3-f0e9-5c4bbed34b6e"
},
"source": [
"pokemon.sort_index(ascending = False).head()"
],
"execution_count": 165,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>#</th>\n",
" <th>Name</th>\n",
" <th>Type 1</th>\n",
" <th>Type 2</th>\n",
" <th>Total</th>\n",
" <th>HP</th>\n",
" <th>Attack</th>\n",
" <th>Defense</th>\n",
" <th>Sp. Atk</th>\n",
" <th>Sp. Def</th>\n",
" <th>Speed</th>\n",
" <th>Generation</th>\n",
" <th>Channel</th>\n",
" <th>Legendary</th>\n",
" <th>Universe</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>799</th>\n",
" <td>721</td>\n",
" <td>Volcanion</td>\n",
" <td>Fire</td>\n",
" <td>Water</td>\n",
" <td>600</td>\n",
" <td>80</td>\n",
" <td>110</td>\n",
" <td>120</td>\n",
" <td>130</td>\n",
" <td>90</td>\n",
" <td>70</td>\n",
" <td>6</td>\n",
" <td>Cartoon Network</td>\n",
" <td>True</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>798</th>\n",
" <td>720</td>\n",
" <td>HoopaHoopa Unbound</td>\n",
" <td>Psychic</td>\n",
" <td>Dark</td>\n",
" <td>680</td>\n",
" <td>80</td>\n",
" <td>160</td>\n",
" <td>60</td>\n",
" <td>170</td>\n",
" <td>130</td>\n",
" <td>80</td>\n",
" <td>6</td>\n",
" <td>Cartoon Network</td>\n",
" <td>True</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>797</th>\n",
" <td>720</td>\n",
" <td>HoopaHoopa Confined</td>\n",
" <td>Psychic</td>\n",
" <td>Ghost</td>\n",
" <td>600</td>\n",
" <td>80</td>\n",
" <td>110</td>\n",
" <td>60</td>\n",
" <td>150</td>\n",
" <td>130</td>\n",
" <td>70</td>\n",
" <td>6</td>\n",
" <td>Cartoon Network</td>\n",
" <td>True</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>796</th>\n",
" <td>719</td>\n",
" <td>DiancieMega Diancie</td>\n",
" <td>Rock</td>\n",
" <td>Fairy</td>\n",
" <td>700</td>\n",
" <td>50</td>\n",
" <td>160</td>\n",
" <td>110</td>\n",
" <td>160</td>\n",
" <td>110</td>\n",
" <td>110</td>\n",
" <td>6</td>\n",
" <td>Cartoon Network</td>\n",
" <td>True</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" <tr>\n",
" <th>795</th>\n",
" <td>719</td>\n",
" <td>Diancie</td>\n",
" <td>Rock</td>\n",
" <td>Fairy</td>\n",
" <td>600</td>\n",
" <td>50</td>\n",
" <td>100</td>\n",
" <td>150</td>\n",
" <td>100</td>\n",
" <td>150</td>\n",
" <td>50</td>\n",
" <td>6</td>\n",
" <td>Cartoon Network</td>\n",
" <td>True</td>\n",
" <td>Pokemon</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" # Name Type 1 ... Channel Legendary Universe\n",
"799 721 Volcanion Fire ... Cartoon Network True Pokemon\n",
"798 720 HoopaHoopa Unbound Psychic ... Cartoon Network True Pokemon\n",
"797 720 HoopaHoopa Confined Psychic ... Cartoon Network True Pokemon\n",
"796 719 DiancieMega Diancie Rock ... Cartoon Network True Pokemon\n",
"795 719 Diancie Rock ... Cartoon Network True Pokemon\n",
"\n",
"[5 rows x 15 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 165
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Nv9b9YL-DrGw",
"outputId": "81202470-a63a-4f8b-e06a-21aac905232d"
},
"source": [
"# Assign a rank to each pokemon based on their HP. Highest HP gets rank 1, lowest HP gets rank last number\n",
"pokemon['HP'].rank(ascending = False).head()"
],
"execution_count": 169,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"0 679.5\n",
"1 495.0\n",
"2 215.0\n",
"3 215.0\n",
"4 751.5\n",
"Name: HP, dtype: float64"
]
},
"metadata": {
"tags": []
},
"execution_count": 169
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 203
},
"id": "vBhQ2GIfD4HK",
"outputId": "4b4632b3-5446-4f90-99ae-9cf4e1205fd9"
},
"source": [
"pokemon['HP Rank'] = pokemon['HP'].rank(ascending = False).astype(int)\n",
"pokemon.sort_values(by = 'HP Rank', ascending = True).head()"
],
"execution_count": 172,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>#</th>\n",
" <th>Name</th>\n",
" <th>Type 1</th>\n",
" <th>Type 2</th>\n",
" <th>Total</th>\n",
" <th>HP</th>\n",
" <th>Attack</th>\n",
" <th>Defense</th>\n",
" <th>Sp. Atk</th>\n",
" <th>Sp. Def</th>\n",
" <th>Speed</th>\n",
" <th>Generation</th>\n",
" <th>Channel</th>\n",
" <th>Legendary</th>\n",
" <th>Universe</th>\n",
" <th>HP Rank</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>261</th>\n",
" <td>242</td>\n",
" <td>Blissey</td>\n",
" <td>Normal</td>\n",
" <td>NaN</td>\n",
" <td>540</td>\n",
" <td>255</td>\n",
" <td>10</td>\n",
" <td>10</td>\n",
" <td>75</td>\n",
" <td>135</td>\n",
" <td>55</td>\n",
" <td>2</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>121</th>\n",
" <td>113</td>\n",
" <td>Chansey</td>\n",
" <td>Normal</td>\n",
" <td>NaN</td>\n",
" <td>450</td>\n",
" <td>250</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>35</td>\n",
" <td>105</td>\n",
" <td>50</td>\n",
" <td>1</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>217</th>\n",
" <td>202</td>\n",
" <td>Wobbuffet</td>\n",
" <td>Psychic</td>\n",
" <td>NaN</td>\n",
" <td>405</td>\n",
" <td>190</td>\n",
" <td>33</td>\n",
" <td>58</td>\n",
" <td>33</td>\n",
" <td>58</td>\n",
" <td>33</td>\n",
" <td>2</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>351</th>\n",
" <td>321</td>\n",
" <td>Wailord</td>\n",
" <td>Water</td>\n",
" <td>NaN</td>\n",
" <td>500</td>\n",
" <td>170</td>\n",
" <td>90</td>\n",
" <td>45</td>\n",
" <td>90</td>\n",
" <td>45</td>\n",
" <td>60</td>\n",
" <td>3</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>655</th>\n",
" <td>594</td>\n",
" <td>Alomomola</td>\n",
" <td>Water</td>\n",
" <td>NaN</td>\n",
" <td>470</td>\n",
" <td>165</td>\n",
" <td>75</td>\n",
" <td>80</td>\n",
" <td>40</td>\n",
" <td>45</td>\n",
" <td>65</td>\n",
" <td>5</td>\n",
" <td>Cartoon Network</td>\n",
" <td>False</td>\n",
" <td>Pokemon</td>\n",
" <td>5</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" # Name Type 1 ... Legendary Universe HP Rank\n",
"261 242 Blissey Normal ... False Pokemon 1\n",
"121 113 Chansey Normal ... False Pokemon 2\n",
"217 202 Wobbuffet Psychic ... False Pokemon 3\n",
"351 321 Wailord Water ... False Pokemon 4\n",
"655 594 Alomomola Water ... False Pokemon 5\n",
"\n",
"[5 rows x 16 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 172
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "hJW1LLMVFNC-"
},
"source": [
"### Filtering DataFrames"
]
},
{
"cell_type": "code",
"metadata": {
"id": "xjbLq1u6E0o4"
},
"source": [
""
],
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment