<jupyter_start><jupyter_text>Data Science with Python and Dask Chapter 3 - Introducing Dask DataFrames  Section 3.1<jupyter_code># Listing 3.1
person_IDs = [1,2,3]
person_last_names = ['Smith', 'Williams', 'Williams']
person_first_names = ['John', 'Bill', 'Jane']
person_DOBs = ['1982-10-06', '1990-07-04', '1989-05-06']<jupyter_output><empty_output><jupyter_text>Section 3.2.1<jupyter_code># Listing 3.2
import pandas as pd
import dask.dataframe as dd

# Creating all the data as lists
person_IDs = [1,2,3,4,5,6,7,8,9,10]
person_last_names = ['Smith', 'Williams', 'Williams','Jackson','Johnson','Smith','Anderson','Christiansen','Carter','Davidson']
person_first_names = ['John', 'Bill', 'Jane','Cathy','Stuart','James','Felicity','Liam','Nancy','Christina']
person_DOBs = ['1982-10-06', '1990-07-04', '1989-05-06', '1974-01-24', '1995-06-05', '1984-04-16', '1976-09-15', '1992-10-02', '1986-02-05', '1993-08-11']

# Storing the data in a Pandas DataFrame
people_pandas_df = pd.DataFrame({'Person ID': person_IDs, 
              'Last Name': person_last_names, 
              'First Name': person_first_names,
             'Date of Birth': person_DOBs},
            columns=['Person ID', 'Last Name', 'First Name', 'Date of Birth'])

# Converting the Pandas DataFrame to a Dask DataFrame
people_dask_df = dd.from_pandas(people_pandas_df, npartitions=2)
# Listing 3.3
print(people_dask_df.divisions)
print(people_dask_df.npartitions)
# Listing 3.4
people_dask_df.map_partitions(lambda x: len(x)).compute()
# Listing 3.5
people_filtered = people_dask_df[people_dask_df['Last Name'] != 'Williams']
print(people_filtered.map_partitions(lambda x: len(x)).compute())

people_filtered_reduced = people_filtered.repartition(npartitions=1)
print(people_filtered_reduced.map_partitions(lambda x: len(x)).compute())<jupyter_output>0    3
1    5
dtype: int64
0    8
dtype: int64
{'fraction_non_alphanumeric': 0.16229244777718266, 'fraction_numerical': 0.07820032137118371, 'mean_word_length': 5.768115942028985, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '138964', 'license': 'MIT', 'n_tokens_mistral': 800, 'n_tokens_neox': 688, 'n_words': 140, 'path': 'dask/dask-book/Chapter 3.ipynb', 'repo_name': 'manual123/Nacho-Jupyter-Notebooks', 'size': '1867'}