Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
  1. As jonrsharpe's comment says, read and follow PEP8. Several things to be improved:
  • You should not import inside a function. All import statements should be at the top of your *.py file.

  • Your variable names could be more descriptive. What is s? What is fn_list? (I know I named some of these variables in my answer to your other question, but I was in a hurry and they could definitely use further improvement.

  1. Your functions don't return anything and don't take in any parameters. That means your modularization of the code is incomplete. The functions are relying on variables in the global namespace. Your main_dataset() function should probably take in either path or filenames as a parameter, for example, so that you don't have to modify your code to use it on different directories or files. That is, instead of def main_dataset():, you should write def main_dataset(path): for example. And it should probably end in return df. That way you don't have load df from the *.csv file again if you are going to use it in downstream analyses. frequency_table() should probably end in return freqDf (although note that freqDf is not a PEP8-recommend variable name).

  2. If you chose, you could make the functions far more versatile by passing many more parameters. frequency_table() could take in a path (as a string) to be used for the output file, so it could save results anywhere. It could also take in neuter and non_neuter as parameters. (Those are good variable names BTW!)

  3. Rather than having your two functions called explicitly at the bottom of the the code, the python idiom is to nest those calls under a if __name__ == "__main__": statement. That way the code is not run if you are just importing your file, but will be run if you call your file from the command line. A very excellent Stack Overflow answerA very excellent Stack Overflow answer has more info on the if __name__ == "__main__": idiom in python.

  1. As jonrsharpe's comment says, read and follow PEP8. Several things to be improved:
  • You should not import inside a function. All import statements should be at the top of your *.py file.

  • Your variable names could be more descriptive. What is s? What is fn_list? (I know I named some of these variables in my answer to your other question, but I was in a hurry and they could definitely use further improvement.

  1. Your functions don't return anything and don't take in any parameters. That means your modularization of the code is incomplete. The functions are relying on variables in the global namespace. Your main_dataset() function should probably take in either path or filenames as a parameter, for example, so that you don't have to modify your code to use it on different directories or files. That is, instead of def main_dataset():, you should write def main_dataset(path): for example. And it should probably end in return df. That way you don't have load df from the *.csv file again if you are going to use it in downstream analyses. frequency_table() should probably end in return freqDf (although note that freqDf is not a PEP8-recommend variable name).

  2. If you chose, you could make the functions far more versatile by passing many more parameters. frequency_table() could take in a path (as a string) to be used for the output file, so it could save results anywhere. It could also take in neuter and non_neuter as parameters. (Those are good variable names BTW!)

  3. Rather than having your two functions called explicitly at the bottom of the the code, the python idiom is to nest those calls under a if __name__ == "__main__": statement. That way the code is not run if you are just importing your file, but will be run if you call your file from the command line. A very excellent Stack Overflow answer has more info on the if __name__ == "__main__": idiom in python.

  1. As jonrsharpe's comment says, read and follow PEP8. Several things to be improved:
  • You should not import inside a function. All import statements should be at the top of your *.py file.

  • Your variable names could be more descriptive. What is s? What is fn_list? (I know I named some of these variables in my answer to your other question, but I was in a hurry and they could definitely use further improvement.

  1. Your functions don't return anything and don't take in any parameters. That means your modularization of the code is incomplete. The functions are relying on variables in the global namespace. Your main_dataset() function should probably take in either path or filenames as a parameter, for example, so that you don't have to modify your code to use it on different directories or files. That is, instead of def main_dataset():, you should write def main_dataset(path): for example. And it should probably end in return df. That way you don't have load df from the *.csv file again if you are going to use it in downstream analyses. frequency_table() should probably end in return freqDf (although note that freqDf is not a PEP8-recommend variable name).

  2. If you chose, you could make the functions far more versatile by passing many more parameters. frequency_table() could take in a path (as a string) to be used for the output file, so it could save results anywhere. It could also take in neuter and non_neuter as parameters. (Those are good variable names BTW!)

  3. Rather than having your two functions called explicitly at the bottom of the the code, the python idiom is to nest those calls under a if __name__ == "__main__": statement. That way the code is not run if you are just importing your file, but will be run if you call your file from the command line. A very excellent Stack Overflow answer has more info on the if __name__ == "__main__": idiom in python.

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link
  1. As jonrsharpe's comment says, read and follow PEP8. Several things to be improved:
  • You should not import inside a function. All import statements should be at the top of your *.py file.

  • Your variable names could be more descriptive. What is s? What is fn_list? (I know I named some of these variables in my answer to your other questionother question, but I was in a hurry and they could definitely use further improvement.

  1. Your functions don't return anything and don't take in any parameters. That means your modularization of the code is incomplete. The functions are relying on variables in the global namespace. Your main_dataset() function should probably take in either path or filenames as a parameter, for example, so that you don't have to modify your code to use it on different directories or files. That is, instead of def main_dataset():, you should write def main_dataset(path): for example. And it should probably end in return df. That way you don't have load df from the *.csv file again if you are going to use it in downstream analyses. frequency_table() should probably end in return freqDf (although note that freqDf is not a PEP8-recommend variable name).

  2. If you chose, you could make the functions far more versatile by passing many more parameters. frequency_table() could take in a path (as a string) to be used for the output file, so it could save results anywhere. It could also take in neuter and non_neuter as parameters. (Those are good variable names BTW!)

  3. Rather than having your two functions called explicitly at the bottom of the the code, the python idiom is to nest those calls under a if __name__ == "__main__": statement. That way the code is not run if you are just importing your file, but will be run if you call your file from the command line. A very excellent Stack Overflow answer has more info on the if __name__ == "__main__": idiom in python.

  1. As jonrsharpe's comment says, read and follow PEP8. Several things to be improved:
  • You should not import inside a function. All import statements should be at the top of your *.py file.

  • Your variable names could be more descriptive. What is s? What is fn_list? (I know I named some of these variables in my answer to your other question, but I was in a hurry and they could definitely use further improvement.

  1. Your functions don't return anything and don't take in any parameters. That means your modularization of the code is incomplete. The functions are relying on variables in the global namespace. Your main_dataset() function should probably take in either path or filenames as a parameter, for example, so that you don't have to modify your code to use it on different directories or files. That is, instead of def main_dataset():, you should write def main_dataset(path): for example. And it should probably end in return df. That way you don't have load df from the *.csv file again if you are going to use it in downstream analyses. frequency_table() should probably end in return freqDf (although note that freqDf is not a PEP8-recommend variable name).

  2. If you chose, you could make the functions far more versatile by passing many more parameters. frequency_table() could take in a path (as a string) to be used for the output file, so it could save results anywhere. It could also take in neuter and non_neuter as parameters. (Those are good variable names BTW!)

  3. Rather than having your two functions called explicitly at the bottom of the the code, the python idiom is to nest those calls under a if __name__ == "__main__": statement. That way the code is not run if you are just importing your file, but will be run if you call your file from the command line. A very excellent Stack Overflow answer has more info on the if __name__ == "__main__": idiom in python.

  1. As jonrsharpe's comment says, read and follow PEP8. Several things to be improved:
  • You should not import inside a function. All import statements should be at the top of your *.py file.

  • Your variable names could be more descriptive. What is s? What is fn_list? (I know I named some of these variables in my answer to your other question, but I was in a hurry and they could definitely use further improvement.

  1. Your functions don't return anything and don't take in any parameters. That means your modularization of the code is incomplete. The functions are relying on variables in the global namespace. Your main_dataset() function should probably take in either path or filenames as a parameter, for example, so that you don't have to modify your code to use it on different directories or files. That is, instead of def main_dataset():, you should write def main_dataset(path): for example. And it should probably end in return df. That way you don't have load df from the *.csv file again if you are going to use it in downstream analyses. frequency_table() should probably end in return freqDf (although note that freqDf is not a PEP8-recommend variable name).

  2. If you chose, you could make the functions far more versatile by passing many more parameters. frequency_table() could take in a path (as a string) to be used for the output file, so it could save results anywhere. It could also take in neuter and non_neuter as parameters. (Those are good variable names BTW!)

  3. Rather than having your two functions called explicitly at the bottom of the the code, the python idiom is to nest those calls under a if __name__ == "__main__": statement. That way the code is not run if you are just importing your file, but will be run if you call your file from the command line. A very excellent Stack Overflow answer has more info on the if __name__ == "__main__": idiom in python.

added link
Source Link
Curt F.
  • 1.6k
  • 11
  • 22
  1. As jonrsharpe's comment says, read and follow PEP8. Several things to be improved:
  • You should not import inside a function. All import statements should be at the top of your *.py file.

  • Your variable names could be more descriptive. What is s? What is fn_list? (I know I named some of these variables in my answer to your other question, but I was in a hurry and they could definitely use further improvement.

  1. Your functions don't return anything and don't take in any parameters. That means your modularization of the code is incomplete. The functions are relying on variables in the global namespace. Your main_dataset() function should probably take in either path or filenames as a parameter, for example, so that you don't have to modify your code to use it on different directories or files. That is, instead of def main_dataset():, you should write def main_dataset(path): for example. And it should probably end in return df. That way you don't have load df from the *.csv file again if you are going to use it in downstream analyses. frequency_table() should probably end in return freqDf (although note that freqDf is not a PEP8-recommend variable name).

  2. If you chose, you could make the functions far more versatile by passing many more parameters. frequency_table() could take in a path (as a string) to be used for the output file, so it could save results anywhere. It could also take in neuter and non_neuter as parameters. (Those are good variable names BTW!)

  3. Rather than having your two functions called explicitly at the bottom of the the code, the python idiom is to nest those calls under a if name__name__ == __main__"__main__": statement. That way the code is not run if you are just importing your file, but will be run if you call your file from the command line. A very excellent Stack Overflow answer has more info on the if __name__ == "__main__": idiom in python.

  1. As jonrsharpe's comment says, read and follow PEP8. Several things to be improved:
  • You should not import inside a function. All import statements should be at the top of your *.py file.

  • Your variable names could be more descriptive. What is s? What is fn_list? (I know I named some of these variables in my answer to your other question, but I was in a hurry and they could definitely use further improvement.

  1. Your functions don't return anything and don't take in any parameters. That means your modularization of the code is incomplete. The functions are relying on variables in the global namespace. Your main_dataset() function should probably take in either path or filenames as a parameter, for example, so that you don't have to modify your code to use it on different directories or files. That is, instead of def main_dataset():, you should write def main_dataset(path): for example. And it should probably end in return df. That way you don't have load df from the *.csv file again if you are going to use it in downstream analyses. frequency_table() should probably end in return freqDf (although note that freqDf is not a PEP8-recommend variable name).

  2. If you chose, you could make the functions far more versatile by passing many more parameters. frequency_table() could take in a path (as a string) to be used for the output file, so it could save results anywhere. It could also take in neuter and non_neuter as parameters. (Those are good variable names BTW!)

  3. Rather than having your two functions called explicitly at the bottom of the the code, the python idiom is to nest those calls under a if name == __main__: statement. That way the code is not run if you are just importing your file, but will be run if you call your file from the command line.

  1. As jonrsharpe's comment says, read and follow PEP8. Several things to be improved:
  • You should not import inside a function. All import statements should be at the top of your *.py file.

  • Your variable names could be more descriptive. What is s? What is fn_list? (I know I named some of these variables in my answer to your other question, but I was in a hurry and they could definitely use further improvement.

  1. Your functions don't return anything and don't take in any parameters. That means your modularization of the code is incomplete. The functions are relying on variables in the global namespace. Your main_dataset() function should probably take in either path or filenames as a parameter, for example, so that you don't have to modify your code to use it on different directories or files. That is, instead of def main_dataset():, you should write def main_dataset(path): for example. And it should probably end in return df. That way you don't have load df from the *.csv file again if you are going to use it in downstream analyses. frequency_table() should probably end in return freqDf (although note that freqDf is not a PEP8-recommend variable name).

  2. If you chose, you could make the functions far more versatile by passing many more parameters. frequency_table() could take in a path (as a string) to be used for the output file, so it could save results anywhere. It could also take in neuter and non_neuter as parameters. (Those are good variable names BTW!)

  3. Rather than having your two functions called explicitly at the bottom of the the code, the python idiom is to nest those calls under a if __name__ == "__main__": statement. That way the code is not run if you are just importing your file, but will be run if you call your file from the command line. A very excellent Stack Overflow answer has more info on the if __name__ == "__main__": idiom in python.

added 4 characters in body
Source Link
Curt F.
  • 1.6k
  • 11
  • 22
Loading
Source Link
Curt F.
  • 1.6k
  • 11
  • 22
Loading