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

create dataframe assumes index and columns are valid #206

Closed
jim-smith opened this issue Jun 3, 2024 · 0 comments · Fixed by #211
Closed

create dataframe assumes index and columns are valid #206

jim-smith opened this issue Jun 3, 2024 · 0 comments · Fixed by #211
Assignees
Labels
enhancement New feature or request

Comments

@jim-smith
Copy link
Contributor

def create_dataframe(index, columns) -> DataFrame:
"""Combining the index and columns in a dataframe and return the datframe.

Parameters
----------
index : array-like, Series, or list of arrays/Series
    Values to group by in the rows.
columns : array-like, Series, or list of arrays/Series
    Values to group by in the columns.

Returns
-------
Dataframe
    Table of the index and columns combined.
"""
if isinstance(index, list):
    index_df = pd.concat(index, axis=1)
elif isinstance(index, pd.Series):
    index_df = pd.DataFrame({index.name: index})
if isinstance(columns, list):
    columns_df = pd.concat(columns, axis=1)
elif isinstance(columns, pd.Series):
    columns_df = pd.DataFrame({columns.name: columns})
data = pd.concat([index_df, columns_df], axis=1)
return data
@jim-smith jim-smith added the enhancement New feature or request label Jun 3, 2024
@jim-smith jim-smith self-assigned this Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant