<jupyter_start><jupyter_text>Task 1<jupyter_code>import pandas as pd
import numpy as np<jupyter_output><empty_output><jupyter_text>***read csv***<jupyter_code>df = pd.read_csv('../csv_data/pre_process_1.csv')
df<jupyter_output><empty_output><jupyter_text>***Create a new column of 'personID' and save it to a file***<jupyter_code>df.info()
personID = pd.DataFrame({'PersonID': range(1,11)})
personID
df = pd.concat([personID, df], axis=1)
df<jupyter_output><empty_output><jupyter_text>***Add new rows in the data-frame***<jupyter_code>new_data = pd.DataFrame({'PersonID': [11, 12, 13],
                      'Country': ['India', 'Australia', 'France'],
                      'Age': ['NaN', 55, 82],
                      'Salary':['NaN', 46000, 30000],
                      'Purchased': ['Yes', 'Yes', 'Yes',]
                  })
new_data
df = pd.concat([df, new_data])
df = df.reset_index().drop('index', axis=1)
df<jupyter_output><empty_output><jupyter_text>***creating a new dataframe for merging***<jupyter_code>df1 = pd.DataFrame({
    'ID': range(1, 14),
    'Height': 5 + np.random.sample(13)*5,
    'Weight': 30 + np.random.sample(13)*10
})
df1<jupyter_output><empty_output><jupyter_text>***merge df and df1***<jupyter_code>final_df = df.merge(df1, left_on='PersonID', right_on='ID').drop('ID', axis=1)
final_df<jupyter_output><empty_output><jupyter_text>***using melt function to melt down columns (not included in final_df)***<jupyter_code>final_df.melt(id_vars=['PersonID','Country','Age','Salary','Height','Weight'], var_name='Ori_Purchased', value_name='Purchased')
replace_purchased = final_df.Purchased.apply(lambda x : True if x=='Yes' else False)
final_df = final_df.assign(Purchased=replace_purchased)
final_df<jupyter_output><empty_output><jupyter_text>***save to file***<jupyter_code>final_df.to_csv('../csv_output/pre_process_1.csv', index=False)
pd.read_csv('../csv_output/pre_process_1.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17831449126413154, 'fraction_numerical': 0.024152106885919837, 'mean_word_length': 5.831578947368421, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '311086', 'license': 'MIT', 'n_tokens_mistral': 769, 'n_tokens_neox': 726, 'n_words': 115, 'path': 'tutorials/pandas/Task 1.ipynb', 'repo_name': 'smandal047/pyspark-pandas', 'size': '1946'}