Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply lambda function on column #2

Open
cyouh95 opened this issue Jun 19, 2018 · 0 comments
Open

Apply lambda function on column #2

cyouh95 opened this issue Jun 19, 2018 · 0 comments

Comments

@cyouh95
Copy link

cyouh95 commented Jun 19, 2018

When a lambda function only involves a single column - for example, fitness_test_date here:

https://github.com/matthewboehlke/intro-data-capstone-musclehub/blob/97693663a901bf0b6d665d73dd4665e82228931c/Intro_To_Data_Analysis_Matt_Boehlke/musclehub.py#L159

You could call .apply() on just that column:

df['ab_test_group'] = df.fitness_test_date.apply(lambda x: 'A' if x is not None else 'B')

Here, the input x to the lambda function would simply be the value in the fitness_test_date column.

@cyouh95 cyouh95 mentioned this issue Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant