<jupyter_start><jupyter_text>Basics- Slicing and FilteringPerhaps the Most common activities performed on dataframes.using the same data from AirBnB for this example:-https://www.kaggle.com/dgomonov/new-york-city-airbnb-open-data<jupyter_code>import pandas as pd
import numpy as np

df=pd.read_csv("AB_NYC_2019.csv")
df.head(2)<jupyter_output><empty_output><jupyter_text>Slicing columns<jupyter_code># option 1
df["host_name"]
# option 2
df.host_name
# Multiple Columns

df[['host_name','neighbourhood_group']]<jupyter_output><empty_output><jupyter_text>Filtering on rows (mask filtering)<jupyter_code>#option 1- in one line
df[df.host_name=="Taz"] #this returns the values in df where 'taz' is the host
df.host_name=="Taz"#running just this will give a index and boolean (true,false) for rows where 'taz' is the host name<jupyter_output><empty_output><jupyter_text>sum()<jupyter_code>(df.host_name=='Taz').sum() # sums up the count of rows conating the value
# option 2 using a Mask variable
mask= df.host_name=="Taz"
df[mask].head(2)<jupyter_output><empty_output><jupyter_text>- Now Lets Use the mask to find Information Here we are looking for the Quickest and cheapest rooms so filtering the price <1000 and where minimum allowed stay is less that 3 nights  sum-gives us a count of how many such options are availible<jupyter_code>quick_n_cheap= (df.price<100) & (df.minimum_nights<3)
quick_n_cheap.sum()
df[quick_n_cheap].head(2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10655737704918032, 'fraction_numerical': 0.01366120218579235, 'mean_word_length': 7.093922651933702, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 21, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '48886', 'license': 'MIT', 'n_tokens_mistral': 544, 'n_tokens_neox': 514, 'n_words': 142, 'path': 'Basic Data Manupulation/Basics- Slicing and Filtering.ipynb', 'repo_name': 'awes0m/pandaconda', 'size': '1464'}