-
Notifications
You must be signed in to change notification settings - Fork 61
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
Sourcery Starbot ⭐ refactored prakharrathi25/data-storyteller #14
base: main
Are you sure you want to change the base?
Conversation
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found the following improvement in Function app
:
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function app
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
# Load the data | ||
# Load the data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function app
refactored with the following changes:
- Merge append into list declaration [×2] (
merge-list-append
) - Move assignment closer to its usage within a block [×2] (
move-assign-in-block
)
This removes the following comments ( why? ):
# Table to store model and accurcy
|
||
# Use two column technique | ||
col1, col2 = st.beta_columns(2) | ||
|
||
global name, type | ||
# Design column 1 | ||
name = col1.selectbox("Select Column", data.columns) | ||
|
||
# Design column two | ||
current_type = col_metadata[col_metadata['column_name'] == name]['type'].values[0] | ||
print(current_type) | ||
column_options = ['numeric', 'categorical','object'] | ||
current_index = column_options.index(current_type) | ||
|
||
type = col2.selectbox("Select Column Type", options=column_options, index = current_index) | ||
|
||
st.write("""Select your column name and the new type from the data. | ||
To submit all the changes, click on *Submit changes* """) | ||
|
||
|
||
if st.button("Change Column Type"): | ||
|
||
# Set the value in the metadata and resave the file | ||
# col_metadata = pd.read_csv('data/metadata/column_type_desc.csv') | ||
st.dataframe(col_metadata[col_metadata['column_name'] == name]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found the following improvement in Function app
:
if 'models' in os.listdir('../'): | ||
return True | ||
return False | ||
return 'models' in os.listdir('../') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function checkDir
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
) - Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found the following improvement in Function app
:
|
||
elif is_numeric_dtype(df[col[i]]): | ||
ColumnType.append((col[i],"numerical")) | ||
Numerical.append(col[i]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found the following improvement in Function genMetaData
:
uniqueVals = list(np.unique(col)) | ||
uniqueVals.sort() | ||
dict_ = {uniqueVals[i]: i for i in range(len(uniqueVals))} | ||
return dict_ | ||
uniqueVals = sorted(np.unique(col)) | ||
return {uniqueVals[i]: i for i in range(len(uniqueVals))} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function makeMapDict
refactored with the following changes:
- Remove an unnecessary list construction call prior to sorting (
skip-sorted-list-construction
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
redunt = [] | ||
k = 0 | ||
for ind, c in enumerate(corr[y]): | ||
if c<1-threshold: | ||
redunt.append(cols[ind]) | ||
return redunt | ||
return [cols[ind] for ind, c in enumerate(corr[y]) if c<1-threshold] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function getRedundentColumns
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Move assignment closer to its usage within a block (
move-assign-in-block
) - Convert for loop into list comprehension (
list-comprehension
)
newDF = df.drop(columns2Drop, axis = 'columns') | ||
return newDF | ||
return df.drop(columns2Drop, axis = 'columns') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function newDF
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
main
branch, then run: