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

How to use template data: The number of days go out #53

Closed
SM-ins opened this issue Jul 2, 2020 · 6 comments
Closed

How to use template data: The number of days go out #53

SM-ins opened this issue Jul 2, 2020 · 6 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@SM-ins
Copy link

SM-ins commented Jul 2, 2020

Dear Lisphilar(@lisphilar ),

i am getting keyError as "others" in # @marcoferrante estimation's code...,Please help me out if possible...

With regards,
Rakesh

@SM-ins SM-ins added the bug Something isn't working label Jul 2, 2020
@lisphilar
Copy link
Owner

Dear Rakesh @SM-ins ,
Thank you always.
I'm sorry, but I could not reproduce the error.
Could you please share the codes (or URL of your Kaggle notebook) with me?

(Issue template "Request fixing a bug" will be useful.)

@SM-ins
Copy link
Author

SM-ins commented Jul 4, 2020

Dear Rakesh @SM-ins ,
Thank you always.
I'm sorry, but I could not reproduce the error.
Could you please share the codes (or URL of your Kaggle notebook) with me?

(Issue template "Request fixing a bug" will be useful.)

Dear Rakesh @SM-ins ,
Thank you always.
I'm sorry, but I could not reproduce the error.
Could you please share the codes (or URL of your Kaggle notebook) with me?

(Issue template "Request fixing a bug" will be useful.)

Dear Lisphilar(@lisphilar ),
You are welcome.
Please find the code below for the mentioned.

@marcoferrante estimation

_period_of_life_list = [
"nursery", "nursery school", "elementary school", "middle school",
"high school", "university/work", "work", "work", "work", "work",
"retired", "retired", "retired"
]
df = pd.DataFrame(
{
"Age_first": [0, 3, 6, 11, 14, 19, 26, 36, 46, 56, 66, 76, 86],
"Age_last": [2, 5, 10, 13, 18, 25, 35, 45, 55, 65, 75, 85, 95],
"Period_of_life": _period_of_life_list,
"Days": [3, 5, 6, 6, 7, 7, 6, 5, 5, 5, 4, 3, 2]
}
)

Adjustment by author

df["Types"] = df["Period_of_life"].replace(
{
"nursery": "school",
"nursery school": "school",
"elementary school": "school",
"middle school": "school",
"high school": "school",
"university/work": "school/work"
}
)
df["School"] = df[["Types", "Days"]].apply(lambda x: x[1] if "school" in x[0] else 0, axis=1)
df.loc[df["Others"] < 0, "Others"] = 0
df.loc[df.index[1:5], "School"] -= 1
df.loc[df.index[1:5], "Others"] += 1
df.loc[df.index[5], ["School", "Office", "Others"]] = [3, 3, 1]
df[["School", "Office", "Others"]] = df[["Days", "School", "Office", "Others"]].apply(
lambda x: x[1:] / sum(x[1:]) * x[0], axis=1
).astype(np.int64)
df.loc[df.index[6:10], "Others"] += 1
df = df.drop(["Days", "Types"], axis=1)

Show dataset

_out_df = df.copy()
_out_df

ThankYou,
Rakesh

@lisphilar
Copy link
Owner

Dear Rakesh @SM-ins ,
Thank you for your response.
The following codes are necessary.

df["Office"] = df[["Types", "Days"]].apply(lambda x: x[1] if "work" in x[0] else 0, axis=1)
df["Others"] = df["Days"] - df[["School", "Office"]].sum(axis=1)

This must be next to the following code.

df["School"] = df[["Types", "Days"]].apply(lambda x: x[1] if "school" in x[0] else 0, axis=1)

In the future version, I will add a interface of Population Pyramid dataset to CovsirPhy.
Best Regards

@lisphilar lisphilar added question Further information is requested enhancement New feature or request and removed bug Something isn't working labels Jul 4, 2020
@lisphilar lisphilar changed the title Bug How to use template data: The number of days go out Jul 4, 2020
@SM-ins
Copy link
Author

SM-ins commented Jul 4, 2020 via email

@lisphilar
Copy link
Owner

Dear Rakesh @SM-ins ,
Thank you for your confirmation.

@SM-ins
Copy link
Author

SM-ins commented Jul 6, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants