<jupyter_start><jupyter_text>Practice: Subsetting Pandas DataFrames IFor this practice, let's use the `iris` dataset:<jupyter_code># import the pandas package
import pandas as pd
# set the path
path = 'https://raw.githubusercontent.com/GWC-DCMB/curriculum-notebooks/master/'
# this is where the file is located
filename = path + 'SampleData/iris.csv'
# load the iris dataset into a DataFrame
iris = pd.read_csv(filename)<jupyter_output><empty_output><jupyter_text>Get familiar with the dataset:<jupyter_code># take a look at the beginning

iris.head()<jupyter_output><empty_output><jupyter_text>Try subsetting on columns:<jupyter_code># subset the species column

iris['species']
# subset the sepal_length and sepal_width columns

iris[['sepal_length','sepal_width']]
# here's a list of columns we want to keep
columns = ['species', 'petal_width']
# now subset the iris dataframe using the list
iris[columns]<jupyter_output><empty_output><jupyter_text>Try subsetting on rows:<jupyter_code># select the first 10 rows
iris.iloc[:10]
# iris.head(10) # alternative method
# think of another way to select the first 10 rows
iris.head(10)
# iris.iloc[:11] # alternative method
# select rows 15 through 20
iris.iloc[15:21]
# select row 30
iris.iloc[30]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10352941176470588, 'fraction_numerical': 0.018823529411764704, 'mean_word_length': 6.595238095238095, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 1, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '50268', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 463, 'n_tokens_neox': 438, 'n_words': 127, 'path': 'Practices/_Keys/KEY_Practice16_Pandas-Subsetting-I.ipynb', 'repo_name': 'ssorbetto/curriculum-notebooks', 'size': '1275'}