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

Rename dataframe inplace #67

Closed
shantanuo opened this issue Nov 29, 2018 · 5 comments
Closed

Rename dataframe inplace #67

shantanuo opened this issue Nov 29, 2018 · 5 comments
Labels
invalid This doesn't seem right

Comments

@shantanuo
Copy link
Contributor

Is this possible with janitor?
df.clean_names(inplace=True)

@ericmjl
Copy link
Member

ericmjl commented Nov 29, 2018

Currently not possible, it also is unclear to me why an inplace=True kwarg is needed for the pyjanitor family of functions. Every method chained function returns a dataframe, which means all we have to do is to assign the returned dataframe to a variable name.

@shantanuo
Copy link
Contributor Author

"inplace" parameter is not really needed. But I suggested it because a lot of pandas methods use it and clean_function will look like a native pandas method with this.
Which one of these 2 statements look more pythonic?
df=df.clean_names()
df.clean_names(inplace=True)
I guess the user should have both the options available.

@ericmjl
Copy link
Member

ericmjl commented Nov 29, 2018

@shantanuo the expected use case of .clean_names() is usually after the data frame is constructed. Hence the examples:

df = (
    pd.read_csv(...)
    .clean_names()
    # chain more functions down here
)

These design of these functions is such that they should be chained, as opposed to being used on single lines.

@shantanuo
Copy link
Contributor Author

I have never used this style, nor have I seen others chaining immediately after read_*
I am not an expert, I will like to know what does the community think about it.

@ericmjl
Copy link
Member

ericmjl commented Nov 29, 2018

No worries, good to know. Btw, if you're interested in reading more of why I decided to put pyjanitor together, and develop it with the rest of the community, here's a document I'm working on: https://github.com/ericmjl/pyjanitor/blob/whitepaper/paper/manuscript.md

@ericmjl ericmjl added the invalid This doesn't seem right label Dec 4, 2018
@ericmjl ericmjl closed this as completed May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants