<jupyter_start><jupyter_text>Pandas Series<jupyter_code>first_name = pd.Series(["jane", "john", "jasmine", "teddy", "megan", "jeffrey", "edward", "jaime"])
first_name
last_name = pd.Series(["olsen", "Totti", "kennedy", "roosevelt", "fox", "bridges", "scissorhand", "cox"])
last_name
age = pd.Series([34, 28, 13, 45, 51, 36, 18, 65])
age<jupyter_output><empty_output><jupyter_text>DataFrame named customer using the above list of Pandas Series<jupyter_code>customer = pd.DataFrame({"first_name": first_name,"last_name":last_name, "age":age})
customer<jupyter_output><empty_output><jupyter_text>Using masking, select list of customers who are between 20 and 35 in age<jupyter_code>customer[(age > 20) & (age < 35)]<jupyter_output><empty_output><jupyter_text>Using slicing, select every other row. Other rows after masking<jupyter_code>customer.loc[2:8]<jupyter_output><empty_output><jupyter_text>Alternate rows<jupyter_code>customer.loc[::2]<jupyter_output><empty_output><jupyter_text>Using fancy indexing, create a new DataFrame with only "last_name" and "age" columns<jupyter_code>df1= customer[["last_name","age"]]
df1<jupyter_output><empty_output><jupyter_text>Using implicit indexing attribute and slicing, create a new DataFrame with indices between 2 and 5. Indices between 2 and 5 mean, to display indices 3 and 4 (As it is implicit indexing, 5 is not included)<jupyter_code>df2=customer[3:5]
df2<jupyter_output><empty_output><jupyter_text>Inidices from 2 to 4 ((As it is implicit indexing, 5 is not included)<jupyter_code>df3=customer[2:5]
df3<jupyter_output><empty_output><jupyter_text>New DataFrame named customer_amount_nan  by adding another Pandas Series<jupyter_code>total_sales =  pd.Series([32.10, 50.80, 13.00, 98.21, np.NAN, 0.50, None, 77.01])
total_sales
customer_amount_nan =  customer.copy()
customer_amount_nan ['total_sales'] = total_sales
customer_amount_nan<jupyter_output><empty_output><jupyter_text>Using forward fill to fill the missing values<jupyter_code>customer_amount_nan.ffill()<jupyter_output><empty_output><jupyter_text>Using backward fill to fill the missing values<jupyter_code>customer_amount_nan.bfill()<jupyter_output><empty_output><jupyter_text>Filling the missing values with value of 0.00<jupyter_code>customer_amount_nan.fillna(0)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1210412147505423, 'fraction_numerical': 0.03210412147505423, 'mean_word_length': 9.826291079812206, 'pattern_counts': {'":': 3, '<': 50, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '297406', 'license': 'Unlicense', 'n_tokens_mistral': 893, 'n_tokens_neox': 822, 'n_words': 179, 'path': 'Data690_Lecture11_HW_SaidaBabu_pandas.ipynb', 'repo_name': 'iamsaida/python-codes', 'size': '2305'}