<jupyter_start><jupyter_text>SLU1 - Pandas 101: Examples notebook<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>Create a pandas Series with some countries, capital and population<jupyter_code>countries = pd.Series(['Denmark', 'Finland', 'Iceland', 'Norway', 'Greenland', 'Faroe Islands'])
capitals = pd.Series(['Copenhagen', 'Helsinki', 'Reykjavík', 'Oslo', 'Nuuk', 'Tórshavn'])
pop = pd.Series([5724456, 5498211, 335878, 5265158,56483,49188])<jupyter_output><empty_output><jupyter_text>Creating a pandas DataFrame<jupyter_code>nordic_countries = pd.DataFrame({'Country': countries, 'Capital': capitals, 'Population':pop})
nordic_countries<jupyter_output><empty_output><jupyter_text>Adding a new column<jupyter_code>gdp = [306.7 ,  236.8 ,  20.0, 370.4, 2.22 , 2.77]
nordic_countries['gdp'] = gdp
nordic_countries<jupyter_output><empty_output><jupyter_text>Load a file  `pd.read_csv(filepath)` This filepath is specific to the file you want and depends on where you currently are<jupyter_code>iris = pd.read_csv('data/iris.csv')<jupyter_output><empty_output><jupyter_text>Info about the DataFrame<jupyter_code>iris.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 150 entries, 0 to 149
Data columns (total 5 columns):
sepal_length    150 non-null float64
sepal_width     150 non-null float64
petal_length    150 non-null float64
petal_width     150 non-null float64
species         150 non-null object
dtypes: float64(4), object(1)
memory usage: 5.9+ KB<jupyter_text>Printing the top 10 entries<jupyter_code>iris.head(10)<jupyter_output><empty_output><jupyter_text>Printing the bottom 10 entries<jupyter_code>iris.tail(10)<jupyter_output><empty_output><jupyter_text>Shape of the DataFrame<jupyter_code>iris.shape
nr_rows = iris.shape[0]
nr_cols = iris.shape[1]<jupyter_output><empty_output><jupyter_text>Get more information about the numerical features<jupyter_code>iris.describe()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12010178117048347, 'fraction_numerical': 0.05547073791348601, 'mean_word_length': 8.4066985645933, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '336407', 'license': 'MIT', 'n_tokens_mistral': 818, 'n_tokens_neox': 729, 'n_words': 140, 'path': 'units/SLU01_Pandas_101/Examples notebook - SLU1 (Pandas101).ipynb', 'repo_name': 'manuboat/LDSSA', 'size': '1965'}