Biodiversity Project + Questions for Experienced Data Scientists / Programmers

Hello everybody,

I am glad to share my project with you!

During the project i got some questions which might be answered by a more experienced developer:

Question 1:
I created my stacked bar charts for the counts of observations as well as for the proportion of the total populations of the considered category by performing a separate loop for each plot. In contrast, I created the pie charts by a separate function call and if-elif conditions in the beginning of the function.
Which way is more efficient/easier to read/… or is there an more elegant way to perform?

Question 2:
I put much effort in the object oriented programming to write the code in a “clear” way. Is it really worth it or could I just not use OOP?

Question 3:
Using sns.lmplot for a regression does not work for subplots or modifiing the axis ticks / tick labels. Why does it not work when it works for other seaborn plots?

Question 4:
I always tried to write a “generalstic” function, such as for the pie charts. Sometimes it feels like it would be more efficient to write two separate functions (respecively for the status and the parks). What would you recommend to do? When should I decide to write two separate functions instead of one more generalistic?

Thanks in advance and kind regards!

1 Like

Congrats on finishing the project!

I guess I’m wondering why you imported Pandas, NumPy, SciPy, and Seaborn if you didn’t use them but instead created classes for the data frame? Unless it’s easier that way(?)

Pandas is pretty powerful for navigating around a data frame, analysis and cleaning of data.

Concerning lmplot…this might help?

Hello and thanks for your feedback so far!
Tbh your comment is confusing me. I did use Pandas, NumPy, SciPy, and Seaborn in the class (methods). Your comment sounds like creating a class does exclude using the modules above - but it does not.
Regarding my code you see, that I instanciated the class object “dataframe” from the class “DataframeClass”. Using the constructor I call the method “createDataframe()” which does create two dataframes from both CSV files using Pandas and subsequently merge them. The next call of the constructor is to perform the method “cleanDataframe()” which does apply the Pandas methods

to the created dataframe. Could you please point out more precisely why you mean that I did not use the modules?

To lmplot: My problem was not that it did not show the plot generally, but only some matplotlib methods (such as subplot and set x ticks (labels)) does not work. In contrast, the do work for other Seaborn plots.

Kind regards,

I did this project so long ago. Perhaps they changed the requirements.

I meant what is the advantage of creating classes here for these csv files over using built in Pandas methods to do EDA?:
df = pd.read_csv()

Does creating classes use less memory or is it more efficient or something? (I’m asking because I honestly don’t know). It just seems like a lot more time/work to create classes & functions to do EDA for this project.

Do you have a Jupyter (or Colab) Notebook for this project so one can see the output of the code in cells? Plus w/that you can use the markdown cells to describe what you’re doing in your analysis (which is telling a story with the data.)

I’m not sure why certain methods didn’t work for lmplot. Did you check the documentation?

I used built-in Pandas methods in my class as well. As I described - using classes does not exclude using Pandas methods.
From the mothods you mentioned I used df = pd.read_csv(). I did not use the other mentioned methods such as, df.shape, df.describe(), pd.isnull() since I used the debugger to get these information. This does not mean that I did not use further Pandas methods to filter and modify the dataframes.

I am also just guessing that the code runs more efficient using classes. But yes - since I put a lot of effort in to create the classes and deal with their methods I hoped to get the opinion of a experienced developer who might know this.

I tried to write a code with the least lines. Since I do not I do not need methods such as ‘.info()’ using PyCharm I decided to stick with this IDE.

Unfortunatelly, it was the first thing I did and could not figure it out yet.

I would consider myself to be a pretty experienced data person and I can say that all the projects that I have reviewed no one used classes. So, this is unique here (not a bad thing at all!). Like I said, I think it’s a bit more time consuming to do and maybe that’s why others didn’t go this route.

But, the point of this project isn’t just writing fewer lines of code; it’s EDA and hypothesis testing. This includes presentation of the data, which is why I asked about using Jupyter or Colab (which is based on Jupyter and cloud-based. It’s an app that you can add to your Google drive and then you can push notebooks to your GitHub repo). So, when you’re going through the data then whoever is viewing your project—whether they’re another data person or someone who has zero experience in data–they can see your thought processes as you weed through the data sets (EDA), test hypotheses, and create graphs and plots. When one only looks at a .py file one cannot see code output.

I’m going to keep investigating this lmplot issue though b/c I’m stumped.

Just to make sure that you did not get me wrong: I meant not to say that you are not an experienced data scientist - but the question concerning classes is rather directed to experienced software developer or whatever.

I know, but after writing the code itself I tried to optimize it and generalize it as far as possible.

This might be the point to work on for me!

1 Like