When done properly, this is not plagiarism—in fact, it is good practice in data science.
It feels really good when you can solve a situation with your own code and your solution is elegant and well crafted. However, in the real world, you often don't have the luxury of enough time to solve certain questions presented and there is rarely a situation presented that hasn't been solved by someone else. It's a balancing act to be sure, but programmers build communities to make solutions stronger and more efficient over time, there is no shame in using that to your advantage!