Posts

Fixing Order of OrderedDict in Pandas

Image
Fixing Order of OrderedDict in Pandas This week I've been working on the same issue from my last week's blog. This week I was producing a solution to the issue, taking into account the requests of the moderators. Although I made a pull request and think I'm on the right track, I'm waiting for the moderators to give some feedback on my pull request before I proceed any further. Overview of the Issue https://github.com/pandas-dev/pandas/issues/21510 The creator of the issue has brought attention to a bug that is caused when combining concat function and OrderedDict. OrderedDict is an ordered dictionary, which means that the dictionary should remember the order of the items added to this dictionary. However, when combining this dictionary with concat, the order gets lost. Here are the observations: In [ 2 ]: from collections import OrderedDict In [ 3 ]: pd.concat(OrderedDict([( ' First ' , pd.Series( range ( 3 ))), ... : ...

Using Unit Tests to Fix a Bug in Pandas

Image
Using Unit Tests to Fix a Bug in Pandas The issue that I decided to work on this week is one of the issues I mentioned two weeks ago when I was planning my work for the next couple of months. This time, I'm expanding on my knowledge of unit tests in Pandas from last week and using them to my advantage to fix an outstanding bug. Overview of the Issue https://github.com/pandas-dev/pandas/issues/21510 The following issue has been posted on June 16, 2018. It's a pretty old issue and one person attempted to solve it. However, the moderators requested changes from the person working on the issue and he never committed anything that would satisfy their requests. After a while, one of the moderators stated that the pull request is now stale and closed it.  On December 2, 2018 after ensuring that the issue was not yet resolved, one of the moderators updated the issue to have a "Contributions Welcome" milestone. Seeing that the moderators are still inter...

Unit Tests in Pandas

Image
Contributing Unit Tests to Pandas The issue that I decided to work on this week was one of the easier issues discussed in my last blog, however it gave me valuable experience with unit testing in Python and Pandas specifically. I decided to start my 2019 open-source contributions with unit testing because I haven't had much experience with unit testing previously in Python.  Overview of the Issue https://github.com/pandas-dev/pandas/issues/21205 As I previously stated in my last blog, this issue shed light on an issue with using NaT when converting a Series to a Period using the dt.to_period('D') function. Other datetime64[ns] objects with values have no problem converting into a Period, however when a NaT was passed in, it stayed as datetime64[ns]. NaT represents a missing value for datetime objects. Since the issue was posted, it has been resolved with current updates to the master branch. However, one of the moderators asked for unit tests that would ens...

Planning Pandas Contributions for the Next Month

Image
Outstanding Pandas Issues Currently Pandas has over 2,700 issues that are still open. Most of these issues are currently taken by somebody or are being worked on. However, with such a big project and so many issues, some people don't succeed in solving what they started, or simply lost interest in solving the issue that they asked to work on. Once the moderators notice that the issue is no longer being worked on, they close the stale pull requests referencing the issue and try to update the issue in order to let people know that it still needs to be solved. This week I went on a hunt for abandoned issues from 2017 and 2018. There are three issues that I found that I would like to work on within the next month and attempt to solve them. In addition to the three issues, I have found some extra issues that I would be working on in case I'm unsuccessful with any of the top three issues. Issue 1 - Casting Data Types https://github.com/pandas-dev/pandas/issues/21513 ...

New Year - New Open-Source Contributions

Image
Project Considerations for Beginning of 2019 After exploring different aspects of open-source for a few months and blogging about what I've been exploring, it was nice to take a few weeks off and go on a vacation. However, 2019 has begun and I'm well rested and ready to jump back into contributing more to big open-source projects and exploring more difficult bugs. For the next few months I will most likely focus on one major open-source project in order to try to fix complicated bugs that might take me a long time to figure out. So in order to not waste time on startup costs of exploring a new project, I will focus all my time fixing complex bugs in a single project. Although I would like to continue working on Pandas, it is important for me to explore a couple other options that I would be interested in. In this blog I will talk about 3 projects that I'm considering to work on for the next few months. Project 1 - Pandas Pandas is a famous open-source library for...

Open Source Contribution - Release 0.4 Part 3

Image
Linting Errors in Pandas Building onto the previous blog where I explored style and linting errors in the pySearch project and the tools used to find these errors, last week I was dealing with similar issues in Pandas. On top of the Flake8 and PEP8 Speaks that the Pandas project uses, they also integrated their own script file that checks for their custom made errors. Since I already explored Flake8 and PEP8 Speaks in-depth, I decided to focus on custom errors within Pandas and to find ways to solve the errors which are difficult to find the origin for. GL07 Error The error that I focused on fixing last week was: GL07 - Sections are in the wrong order. As I stated before, Pandas is a massive project and in order to help developers remember the purpose and use of all the functions, as well as for new contributors to understand the functionalities of the functions within the project, Pandas does a very great job of documenting their code through docstrings within each fu...

Open Source Contribution - Release 0.4 Part 2

Image
Integrating Style Guide Enforcement PEP8 Speaks is one of the many tools to help enforce style in a GitHub project. It is easily integratabtle with any public GitHub project by following the installation instructions from the following link: https://github.com/integration/pep8-speaks Once it is integrated, it can be configured to check for style and linting errors in the changes of Pull Requests. A pep8speaks bot will respond in a comment of the PR if there were any issues.  Similarly to PEP8 Speaks, Flake8 is a good tool to use when checking for style and linting errors locally. In order to install Flake8, you will need to type in the following command: "python -m pip install flake8". After installation you can run the "flake8" command to either check the whole project or specific files. To check your whole project, go into the root folder of your project and type the following command: "flake8 .". To check specific files: "flake8 ex...