teleren/devto huggingface dataset:
How do you handle missing data using pandas?
Tags: python
Published: 2023-08-21 10:11:44

Handling missing data is a critical step in data preprocessing and analysis, and the Pandas library in Python provides several methods and techniques to effectively manage missing values within a DataFrame or Series. 

One common approach is **dropping missing values**, which involves removing rows or columns containing any NaN or null values using the `dropna()` function. While this can be useful when the missing data is minimal or the analysis can tolerate some data loss, it might not be suitable when significant information is discarded.

Another strategy is **imputation**, where missing values are replaced with estimated or calculated values. Pandas provides methods like `fillna()` to replace missing values with specific values, such as mean, median, mode, or a custom value. This approach maintains the integrity of the dataset but introduces potential bias if not carefully handled.

Pandas also offers advanced techniques like **interpolation**, where missing values are estimated based on the existing data points. This can be particularly useful for time series data, where missing values can be inferred from adjacent points using methods like linear interpolation or polynomial fitting.

For categorical data, **mode imputation** using the `fillna()` function can be employed, while for numeric data, **mean, median, or even regression-based imputation** may be considered, depending on the context and distribution of the data.

Additionally, Pandas allows for **forward-fill** and **backward-fill** imputation using the `ffill` and `bfill` methods respectively, which fill missing values with the preceding or succeeding values. These methods can be useful in situations where data has a sequential or time-based structure. Apart from it by obtaining [Master Python Programming](https://www.edureka.co/masters-program/python-developer-training), you can advance your career as a Python. With this course, you can demonstrate your expertise in the basics of to Data Science, Machine Learning, Deep Learning, Natural Language Processing, many more fundamental concepts.

It's important to note that the choice of handling missing data depends on the nature of the dataset, the context of analysis, and the potential impact of imputation on results. Careful consideration is essential to prevent introducing bias or inaccuracies in the analysis. A combination of techniques might be used, and data analysts should evaluate the trade-offs between data completeness and potential distortions in their analysis and modeling.
Javascript Advance DOM Manipulation
Tags: webdev, javascript, programming, tutorial
Published: 2023-08-21 09:56:59

Advanced DOM manipulation in JavaScript involves more complex interactions with the Document Object Model, including creating, modifying, and animating elements, handling events, and working with more advanced techniques. Let's explore some advanced DOM manipulation concepts with examples:

**1. Creating Elements:**

```javascript
const newDiv = document.createElement('div');
newDiv.className = 'new-div';
newDiv.textContent = 'This is a new div element.';
document.body.appendChild(newDiv);
```

**2. Modifying Elements:**

```javascript
const existingDiv = document.querySelector('.existing-div');
existingDiv.textContent = 'Updated content';
existingDiv.classList.add('highlight');
```

**3. Cloning Elements:**

```javascript
const originalDiv = document.querySelector('.original-div');
const clonedDiv = originalDiv.cloneNode(true);
document.body.appendChild(clonedDiv);
```

**4. Event Delegation:**

```javascript
document.addEventListener('click', event => {
  if (event.target.matches('.clickable')) {
    console.log('Clicked on a clickable element:', event.target);
  }
});
```

**5. Animations with CSS Transitions:**

```javascript
<style>
  .fade {
    opacity: 0;
    transition: opacity 1s ease-in-out;
  }
</style>

<div class="fade">Fading Element</div>

<script>
  const fadeElement = document.querySelector('.fade');
  setTimeout(() => {
    fadeElement.style.opacity = 1;
  }, 1000);
</script>
```

**6. Animations with requestAnimationFrame:**

```javascript
function animateElement() {
  const element = document.querySelector('.animated');
  let position = 0;

  function step() {
    position += 2;
    element.style.left = position + 'px';

    if (position < 200) {
      requestAnimationFrame(step);
    }
  }

  requestAnimationFrame(step);
}
```

**7. Creating Complex UI Components:**

```javascript
class Accordion {
  constructor(container) {
    this.container = container;
    this.headers = this.container.querySelectorAll('.accordion-header');

    this.headers.forEach(header => {
      header.addEventListener('click', () => this.togglePanel(header));
    });
  }

  togglePanel(header) {
    const panel = header.nextElementSibling;
    panel.classList.toggle('active');
  }
}

const accordionContainer = document.querySelector('.accordion-container');
const accordion = new Accordion(accordionContainer);
```

**8. Virtual DOM Manipulation with Libraries (React, Vue):**

Using libraries like React or Vue.js can simplify complex DOM manipulation scenarios by abstracting away direct manipulation and providing a virtual DOM that optimizes updates
SSL, TLS, and mTLS
Tags: systemdesign, ssl, tls, mtls
Published: 2023-08-21 09:46:13

System Design has many background concepts that might not sound so important but are always good to keep in mind. Similar concepts are some communication protocols like SSL, TLS, and mTLS.

## SSL (Secure Sockets Layer)

SSL is a protocol that encrypts and secures communication happening over the internet. Though it was already developed in 1995, it has been deprecated in favor of Transport Layer Security (TLS). However, it is still called an SSL certificate because most of the significant certificate with SSL provides the certificate with the same name.

### Why is SSL essential?

SSL was created so that not everyone can read the data transmitted during communication on the internet. It protects user privacy and doesn’t let anyone intercept the data.

This happens when SSL encrypts the data and stops possible cyber attacks when it prevents attackers in the transit itself.

## TLS (Transport Layer Security)

As mentioned earlier, TLS is a deprecated version of SSL. It works for privacy and data security for communications over the internet between web applications and servers.

The components involved in TLS protocols are: -

### Encryption

It hides the data so it can’t be transferred from or to third parties without proper authentication.

### Authentication

It verifies whether the parties involved are who they claim to be.

### Integrity

It verifies if the data have been tampered with.

## mTLS (Mutual TLS)

Moving on, we have mTLS which means the parties at each end of the network connection need to be authenticated. It happens by checking that they all have the correct private keys. In addition, their individual TLS certificates add to the verification process.

### Why use mTLS?

mTLS are commonly seen in [microservice architectures](https://dev.to/pragyasapkota/microservices-21oe) and [distributed systems](https://dev.to/pragyasapkota/distributed-system-the-definition-nkh) in a [zero-trust security model](https://en.wikipedia.org/wiki/Zero_trust_security_model) to verify each other. The mTLS ensures the secured traffic on both servers and the client’s part. It has an additional layer of security for the users who log in to the network or applications. Moreover, it verifies the connection with the client who has devices that don’t follow the login process as the Internet of Things (IoT).

**_I hope this article was helpful to you._**

**_Please don’t forget to follow me!!!_**

**_Any kind of feedback or comment is welcome!!!_**

**_Thank you for your time and support!!!!_**

**_Keep Reading!! Keep Learning!!!_**
React Vite 404 error upon deploying on GitHub
Tags: javascript, react, github, vite
Published: 2023-08-21 09:05:15

Have you ever encountered a 404 error when deploying your React Vite project on GitHub? Don't worry, you're not alone! Many developers have faced this issue, scratching their heads and wondering what went wrong. In this article, we'll explore some common reasons for this error and how to fix it.

What is React Vite?
-------------------

Before we dive into the problem, let's quickly recap what React Vite is. React Vite is a fast build tool for React applications. It aims to provide instant feedback and lightning-fast development experience by leveraging the power of Vite's dev server.

The Mysterious 404 Error
------------------------

So, you've successfully built your React Vite project and pushed it to GitHub. Excitedly, you visit the deployed GitHub Pages URL, only to be greeted by a 404 error. What gives?

One possible reason for this error is the incorrect configuration of the `base` option in your Vite configuration file (`vite.config.js`). This option specifies the base path for your project when it's deployed. If it's not set correctly, GitHub Pages won't be able to find your files.

To fix this issue, open your `vite.config.js` file and make sure the `base` option is set to the correct path. For example, if your repository name is "my-awesome-project," the base option should be set to "/my-awesome-project/".

Another common culprit for the 404 error is the incorrect routing configuration. If you're using React Router or any other routing library, make sure your routes are set up correctly. GitHub Pages relies on the URL path to serve the appropriate content, so any misconfiguration can result in a 404 error.

Deploying with GitHub Actions
-----------------------------

If you're using GitHub Actions to automate your deployment process, there might be some additional steps you need to take. Ensure that your deployment workflow correctly builds and deploys your React Vite project. Double-check the build script and make sure it's generating the necessary files.

Remember, debugging deployment issues can be frustrating, but it's also an opportunity to learn and grow as a developer. Don't be afraid to dive into the documentation, ask for help from the community, or even crack a few jokes to lighten the mood!

In Conclusion
-------------

Encountering a 404 error when deploying your React Vite project on GitHub can be a headache. However, by checking your Vite configuration, ensuring correct routing, and verifying your deployment workflow, you can overcome this issue and successfully deploy your project. Happy coding!

### References:

*   React Vite documentation: [https://vitejs.dev/guide/](https://vitejs.dev/guide/)
*   GitHub Pages documentation: [https://docs.github.com/en/pages](https://docs.github.com/en/pages)
*   React Router documentation: [https://reactrouter.com/](https://reactrouter.com/)
Gatsby SSR docker image size is too large
Published: 2023-08-21 08:56:14

Hi all, I am facing issue while deploying Gatsby SSR code to GCP using docker as an image container.
The image size is coming more than 3.0GB which is heavy for handling load and autoscaling in GCP.

Right now using single stage build in Docker
Where building the application first using Gatsby build and then serving it on a port using Gatsby serve command.

Because node modules are also part of the image so size is very high.

Tried nginx multi-stage build as well but that didn't work because it is not able to find the index.html in the root of the build folder.

This is another issue index.html is not getting generated after running Gatsby build in my Gatsby SSR application

Please help me reduce the image size at most priority.
Kotlin Code Smell 31 - Not Polymorphic
Tags: kotlin, codesmells, cleancode, programming
Published: 2023-08-21 10:16:11

---
title: Kotlin Code Smell 31 - Not Polymorphic
published: true
date: 2023-08-21 08:34:11 UTC
tags: kotlin,codesmells,cleancode,programming
canonical_url: https://yonatankarp.com/kotlin-code-smell-31-not-polymorphic
---

## Problems

- Missed Polymorphism
- Coupling
- IFs / Type check Polluting.
- Names are coupled to types.

## Solutions

1. Rename methods after what they do.
2. Favor polymorphism.

## Sample Code

### Wrong

```kotlin
class Array {
    fun arraySort() { ... }
}

class List {
    fun listSort() { ... }
}

class Set {
    fun setSort() { ... }
}

```

### Right

```kotlin
interface Sortable {
    fun sort()
}

class Array : Sortable {
    override fun sort() { ... }
}

class List : Sortable {
    override fun sort() { ... }
}

class Set : Sortable {
    override fun sort() { ... }
}

```

## Conclusion

Naming is very important. We need to name concepts after what they do, not after accidental types.

* * *

I hope you enjoyed this journey and learned something new. If you want to stay updated with my latest thoughts and ideas, feel free to register for my [**newsletter**](https://yonatankarp.com/newsletter). You can also find me on [**LinkedIn**](https://www.linkedin.com/in/yonatankarp/) or [**Twitter**](https://twitter.com/yonatan_karp). Let's stay connected and keep the conversation going!

* * *

## Credits

- [Code Smell 45 - Not Polymorphic](https://maximilianocontieri.com/code-smell-45-not-polymorphic) by [Maxi Contieri](https://hashnode.com/@mcsee)
Join us for our daily demo and get a free trial for IAST
Tags: iast, application, security, cybersecurity
Published: 2023-08-21 08:40:28

Join us for our daily demo and get a free trial for IAST(interactive application security testing)!!!
What you will get to know:

Ready to go & Simple configuration
SaaS Solution: spare your hardware investment, no installation/tunning
Quick Start: launch an app test with just a few commands
Advanced features: more configurations for deeper analysis and custom rules

Register below:
(https://alt.jotfor.ms/232321514296451)
Kick start your coding journey with this course!
Tags: coding, webdev, programming
Published: 2023-08-21 08:30:12

Hey there, fellow developers! 🖥️ Throughout your coding journey, you're bound to dive into numerous courses to sharpen your skills. 💪 Video tutorials, especially for beginners, are like a guiding light 🌟. Instructors handpick the content, sparing you the hassle of wading through documentation and scouring resources. Trust me, while documentation is a top-notch way to learn, it can be a bit much for newcomers. Personally, I see myself as an "advanced beginner" (if that's even a thing!). I've crafted software, tackled multiple projects, and even led some teams. Still, for completely fresh concepts, I find solace in video tutorials. And that's A-OK! Balancing video tutorials with reading docs? That's the sweet spot. 🎯

Having said that, let me rave about one course that truly upped my programming game: CS50X by Harvard University. 🏛️ This gem is free, folks! If you're chasing a certificate, a small fee might be involved. Ivy League universities in the US are all about generosity. MIT, for instance, dishes out courses through MIT Open Courseware—for zilch! 🌈 CS50X, Harvard's baby, is no different. Ready for a game-changer? Check it out here.

CS50 is a grand tour of Computer Science 101. Scratch, a newbie-friendly programming language, sets the stage. Then, it's all about C programming: conditionals, loops, functions, arrays, algorithms, memory—yep, the works. Oh, did I mention C is just the appetizer? Next up: Python and SQL strut onto the scene. And to wrap things up with a flourish, enter web tech—HTML, CSS, JavaScript, and Flask (Python's trusty sidekick). It's like a knowledge feast with practical application as the dessert. 🍰

Why's CS50 a standout? Well, that's all thanks to the charismatic instructor, David J. Malan. His explanations are like a gentle stream of comprehension. Sure, he might set a brisk pace—no biggie! Just slow it down if you need. 🐢 The visuals? Cinematic! It's not your usual voice-over gig; David uses non-verbal magic to keep us captivated. Plus, they sprinkle the course with rich materials and projects. 🎬

This course? A rocket launch for my programming journey. Strong foundations? Check! This course has it covered. With focused attention, I devoured each lecture without distractions. And guess what? No note-taking headaches; they've got slick resources like slides in place. 📑 Chew on each concept before moving ahead—that's the golden rule. Don't rush this masterpiece of learning!

Here's my tip: 🌟 CS50X is a must for beginners! They're not one-trick ponies; CS50 offers a buffet of courses—web development, AI, game dev, you name it. But this particular gem is your "Intro to CS" starter pack. Trust me, it's like the programmer's compass pointing north. 🧭 Take it at your pace, savor every byte of knowledge. This course turned the tides for me, and I'd recommend it to beginners any day. 🌞
First Code Crush: Which Language Feels Like Home?
Tags: discuss, codenewbie, beginners
Published: 2023-08-21 08:28:13


We all have that one language that just clicks. Which language are you naturally drawn to for your projects? Share your stories and what makes it your comfort go-to!


Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more discussions and online camaraderie!

*{% embed* https://dev.to/codenewbieteam *%}*
Tech Upgrades: When to Make the Jump?
Tags: discuss
Published: 2023-08-21 08:21:02

Switching to newer tech in coding can be a gamble. How do you choose? Tell us about a project you upgraded & what drove the change.

Follow the DEVteam for more discussions and online camaraderie!

{% embed [https://dev.to/devteam](https://dev.to/devteam) %}
Can you automate order management on Odoo with chat-GPT?
Tags: odoo, ai, chatgpt, llm
Published: 2023-08-21 08:13:30

We believe that by combining Odoo with large language models (LLMs) like GPT-4 you can fully automate order management. LLMs are great at automating all the edge cases that you don't have time to automate with rules/routes on Odoo.

Let's take an example: did the "inbound logistics" team remember to process the receipt of product 0022 that you need in order to deliver backorder 0123 ASAP?

To answer this question you need to triangulate between data from your purchase order, the supplier, the carrier and receipts in the inventory module. You can do this with queries or manually checking and sending reminders to the inbound logistics team.

Or you can simply ask an LLM to monitor the data for you and notify you and the inbound logistic team as soon as the product is arrived.

The trick is to train the LLM to understand order management processes. This is what we've been doing. We'd love to get your feedback and expert insights on our early beta on the odoo app store: https://apps.odoo.com/apps/modules/16.0/fulfillment_copilot/
How to find the downloaded image if &#47;var&#47;lib&#47;docker does not exists?
Tags: docker, ubuntu
Published: 2023-08-21 08:06:16

So, you're a software developer working with Docker and you've encountered an issue. You're trying to find a downloaded image, but the `/var/lib/docker` directory doesn't exist. Don't panic! We've got you covered.

First, let's understand why the `/var/lib/docker` directory might not exist. Docker stores its images, containers, and volumes in this directory by default. However, it's possible that your Docker installation might have a different configuration or that you're using a different storage driver.

To find the downloaded image, you can follow these steps:

1.  Check the Docker configuration: Run the command `docker info` in your terminal to get information about your Docker installation. Look for the "Docker Root Dir" field to find the location where Docker is storing its data.
2.  Navigate to the Docker data directory: Once you have the Docker root directory, navigate to it using the command `cd <docker\_root\_directory>`. For example, if your Docker root directory is `/home/user/docker`, run `cd /home/user/docker`.
3.  Search for the downloaded image: Use the command `sudo find . -name <image_name>.tar` to search for the downloaded image. Replace `<image_name>` with the name or part of the name of the image you're looking for. This command will search for files with a `.tar` extension, which is the format Docker uses to store images.
4.  If you find the image, note down the path: Once the command completes, it will display the path of the image if it exists. Note down the path for future reference.

Now, you should have successfully found the downloaded image even if the `/var/lib/docker` directory doesn't exist.

Remember, it's essential to have a sense of humor while troubleshooting technical issues. Here are a couple of funny phrases to lighten up your day:

*   "Finding a missing directory is like searching for a needle in a stack of hay. But fear not, we'll locate that elusive image!"
*   "If Docker were a detective, it would be Sherlock Holmes. Let's put on our detective hats and find that image!"

We hope this guide helped you find the downloaded image you were looking for. If you have any further questions or need assistance, don't hesitate to reach out to the Docker community or consult the references below.

References:

*   [Docker documentation: Docker info command](https://docs.docker.com/engine/reference/commandline/info/)
*   [Linux man page: find command](https://man7.org/linux/man-pages/man1/find.1.html)
Mastering IF THEN Logic in SQL Server
Published: 2023-08-21 07:55:44

In the world of database management, having a firm grasp of T-SQL control-of-flow statements is a crucial skill. These statements allow developers to dynamically control the flow of program execution, making complex logic implementation possible. Among the powerful control-of-flow statements in SQL Server, the IF statement stands out as a fundamental tool. Exploring the advanced usage of IF-THEN statements and understanding how dbForge Studio SQL Server aids in handling these tasks will be the main focus of this article.

Read the article to get more info: https://blog.devart.com/if-then-in-sql-server.html 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yjkvo9nqmj53bzr4ig37.png)