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

feat: Format timestamps as timestamps #230

Merged
merged 7 commits into from Aug 5, 2020
Merged

feat: Format timestamps as timestamps #230

merged 7 commits into from Aug 5, 2020

Conversation

KitBurgess
Copy link
Contributor

Closes #49

Copy link
Contributor

@cvonsteg cvonsteg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 suggestions, 1) on the performance of the datetime casting, and 2) on simplifying the if/else statement

Comment on lines 41 to +46
if columns is None:
return pd.DataFrame(data=data, columns=default_columns)
df = pd.DataFrame(data=data, columns=default_columns)
elif columns == "all":
return pd.DataFrame(data=data)
df = pd.DataFrame(data=data)
else:
return pd.DataFrame(data=data, columns=columns)
df = pd.DataFrame(data=data, columns=columns)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could simplify this slightly

columns = columns or default_columns # handles None 'if' clause
if columns == 'all':
    df = pd.DataFrame(data=data)
else:
    df = pd.DataFrame(data=data, columns=columns)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely fewer lines of code - but I think it's slightly more difficult to read for the user: we mutate the columns variable and then handle it in the if statement - rather than explicitly dealing with the three posibilities for the columns variable..

Copy link
Contributor

@cvonsteg cvonsteg Aug 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your call!

vortexasdk/result_conversions.py Outdated Show resolved Hide resolved
@KitBurgess KitBurgess merged commit 3bd91fe into master Aug 5, 2020
@KitBurgess KitBurgess deleted the timestamp-cols branch August 5, 2020 17:10
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

Successfully merging this pull request may close these issues.

Dataframe timestamp columns in datetime format
3 participants