Etn/fix schedule name merge bug#34
Merged
Merged
Conversation
this fixes as bug where the scheduleNames were being appended to data types that did not have that data, because the merge was happening on "time" instead of "id." In other words, if the another data type happened at the same "time" as the scheduleName, then the schedule data was appended to that row of data as well.
jameno
approved these changes
Oct 29, 2018
Contributor
jameno
left a comment
There was a problem hiding this comment.
I added a suggestion to use the .csv format for retrieving column heads instead of loading in the .json files. It is not a necessary change to complete this pull request.
| # drop and reattach the new data | ||
| df = df.drop(columns=scheduleName) | ||
| df = pd.merge(df, scheduleNameDataFrame.loc[:, ["time", scheduleName]], how="left", on="time") | ||
| df = pd.merge(df, scheduleNameDataFrame.loc[:, ["id", scheduleName]], how="left", on="id") |
| fileSize = os.stat(jsonFileName).st_size | ||
| if fileSize > 1000: | ||
| i = i + 1 | ||
| data = td.load.load_json(jsonFileName) |
Contributor
There was a problem hiding this comment.
If this file ran on a csv version of the files instead, all columns heads will be in the first line, and can be read directly with:
# Read the first line of file
with open(csvFileName, 'r') as f:
header = f.readline()
This would make it easier to loop through files without having to load in the entire JSON file each time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@jameno please review this bug fix when you get a chance. cc: @pazaan, I assume you will want to be aware of this.