<jupyter_start><jupyter_text>Technology Explorers Course 2, Lab 1: Practice with Pandas**Instructor**: <NAME>**Contact**: <EMAIL>---In this lab we will continue to practice with pandas---<jupyter_code>import pandas as pd
import numpy as np<jupyter_output><empty_output><jupyter_text>Q1 Convert the two series into the columns of a DataFrame<jupyter_code>ser1 = pd.Series(list('abcedfghijklmnopqrstuvwxyz'))
ser2 = pd.Series(np.arange(26))

pd.DataFrame([ser1,ser2]).T<jupyter_output><empty_output><jupyter_text>Q2Conver the series into a DataFrame with 7 rows and 5 columns<jupyter_code>ser = pd.Series(np.random.randint(1, 10, 35))<jupyter_output><empty_output><jupyter_text>Q3Compute the difference of differences between consecutive numbers in a series using `ser.diff()`<jupyter_code>ser = pd.Series([1, 3, 6, 10, 15, 21, 27, 35])<jupyter_output><empty_output><jupyter_text>Q4 Convert a series of dates to `datetime` format using `pd.to_datetime()`<jupyter_code>ser = pd.Series(['01 Jan 2010', '02-02-2011', '20120303', '2013/04/04', '2014-05-05', '2015-06-06T12:20'])<jupyter_output><empty_output><jupyter_text>Q5Compute the mean of weights grouped by fruit<jupyter_code>fruit = pd.Series(np.random.choice(['apple', 'banana', 'carrot'], 10))
weights = pd.Series(np.linspace(1, 10, 10))
print(weights.tolist())
print(fruit.tolist())<jupyter_output>[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
['banana', 'banana', 'banana', 'carrot', 'carrot', 'carrot', 'carrot', 'carrot', 'banana', 'banana']<jupyter_text>Q6Compute the euclidian distance between vectors p and q (pythagorean theorem)<jupyter_code>p = pd.Series([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
q = pd.Series([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])<jupyter_output><empty_output><jupyter_text>Q7Fill in missing values for dates with the previous dates' value using `ser.bfill()` or `ser.ffill()`<jupyter_code>ser = pd.Series([1,10,3,np.nan], index=pd.to_datetime(['2000-01-01', '2000-01-03', '2000-01-06', '2000-01-08']))
print(ser)<jupyter_output>2000-01-01     1.0
2000-01-03    10.0
2000-01-06     3.0
2000-01-08     NaN
dtype: float64<jupyter_text>Q8Check if there are missing values in a dataframe using `.isnull()`, `.values`, and `.any()`<jupyter_code>df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/Cars93_miss.csv')<jupyter_output><empty_output><jupyter_text>Q9Grab the first column and return it as a DataFrame rather than as a series<jupyter_code>df = pd.DataFrame(np.arange(20).reshape(-1, 5), columns=list('abcde'))<jupyter_output><empty_output><jupyter_text>Q10In `df`, interchange columns 'a' and 'c'.<jupyter_code>df = pd.DataFrame(np.arange(20).reshape(-1, 5), columns=list('abcde'))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16777286135693215, 'fraction_numerical': 0.084070796460177, 'mean_word_length': 6.773638968481375, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '501472', 'license': 'MIT', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1060, 'n_words': 229, 'path': 'Fundamentals II/SOLUTIONS/SOLUTION_Tech_Fun_C2_L1__Practice_with_Pandas.ipynb', 'repo_name': 'wesleybeckner/technology_explorers', 'size': '2736'}