<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Use pandas to generate a key;value file to submit to the leaderboard
First use a pure Gender based probability approach, where all females will survive
Import modules needed
Step1:  Define path to working csv files, input and output
Step2:  Create a dataframe from the csv file
delimiter is ';', set index to be the 'id', and use only the columns 'id' and 'sex'
Step3:  Add a new column named "survived"
Create a lambda function to pass the logic to the new column on the dataframe
Step4:  Then, apply the lambda function created to a new column "survived"
Step5:  Rename index and column to comply the format to be submitted
Step6:  Done with indexing, from this point, create a new csv file for gender based probability and submit
<ASSISTANT_TASK:>
Python Code:
from pandas import Series, DataFrame
import pandas as pd
Explanation: Use pandas to generate a key;value file to submit to the leaderboard
First use a pure Gender based probability approach, where all females will survive
Import modules needed
End of explanation
f = r'/home/hase/Documents/ZHAW/InfoEng/Lectures/Scripting/data/titanic3_test.csv'
fo = r'/home/hase/Documents/ZHAW/InfoEng/Lectures/Scripting/data/submit/titanic3_test_gender.csv'
Explanation: Define path to working csv files, input and output
End of explanation
df = pd.read_csv(f, sep=';', index_col='id', usecols=['id', 'sex'])
df.head()  # Get the first five rows of the dataframe
Explanation: Create a dataframe from the csv file
delimiter is ';', set index to be the 'id', and use only the columns 'id' and 'sex'
End of explanation
def gender(row):
    if row['sex'] == 'female':
        return 1
    else:
        return 0
Explanation: Add a new column named "survived"
Create a lambda function to pass the logic to the new column on the dataframe
End of explanation
df['survived'] = df.apply(lambda row: gender(row),axis=1)  # axis=1 means it applies to a row level
# Needs to be lambda to a pass a function to df.apply?
df.head()
df.drop('sex', axis=1, inplace=True)   # axis=1 means column-wise, and inplace=True does operation in place
# i.e. no need to do df = df.drop(....)
df.head()
Explanation: Then, apply the lambda function created to a new column "survived"
End of explanation
df.index.name = 'key'
df.index.name
df.rename(columns={'survived':'value'}, inplace=True)
df.head()
Explanation: Rename index and column to comply the format to be submitted
End of explanation
df.to_csv(fo, sep=';')
Explanation: Done with indexing, from this point, create a new csv file for gender based probability and submit
End of explanation
<END_TASK>