teleren/devto huggingface dataset:
Pandas map()function with example
Tags: beginners, pandas, datascience, python
Published: 2022-04-07 21:11:19

Map() function allows us to transform data in a DataFrame or series one value at a time.A dataframe is a table with a value corresponding to a row and column entry.An example of creating a dataframe is as shown: 

```python
import pandas as pd
table=pd.DataFrame({'Age':[16,18,25,27,28,30,45],'Gender':['Female','Male','Female','Male','Male','Male','Female'],'Marks':[66,70,88,90,95,50,88]})
```
The output should look like this

![table DataFrame](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4if6jjfjo75v0l73kjjd.png)
In the above example we created a DataFrame _table_ using _pd.DataFrame()_ having the columns age,gender,marks.Entries are assigned to the respective columns as shown in the square brackets.
Now lets jump into using the map()function


## Mapping female with 1 and male with 0 then displaying result on a different column.

```python
table['sex_num']=table.Gender.map({'Female':1,'Male':0})
table.loc[:,['Gender','sex_num']]
```
_table['sex_num']_ creates a new column sex_num,Gender.map specifies the values to map with in the column Gender. _Dataframe.loc_ is used for accessing multiple columns . In this case we want to access the columns _'Gender'_ and 'sex_num'. 

![Comparison of Gender and sex num](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vavt6ap00sum13vxh9g5.png)

## To find deviation from mean mark

```python
dev_mean=table.Marks.mean()
table['Deviation_From_Mean']=table.Marks.map(lambda p:p-dev_mean)
table.loc[:,['Deviation_From_Mean','Marks']]
```
_table.Marks.mean()_ tells pandas to calculate the marks mean and assign it to _dev_mean._ _table['Deviation_From_Mean']_creates a new column deviation from mean and  maps a lambda function _lambda p:p-dev_mean_ to each value of the column.A lambda function can take a number of arguments & execute an expression. The lambda function has a keyword, a variable and an expression.The keyword is lambda & must be included whenever you're using lambda function. In _lambda p:p-dev_mean_ _p _stands for each of the entries in the marks column. The expression _p-dev_mean_ subtracts  the dev_mean from each of the entries.

![Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7w4ko5w5095d61x6c71.png)
Quem é Pixl Rose?
Tags: braziliandevs, womenintech
Published: 2022-04-07 20:49:01

## Quem é Pixl Rose para você?
Meu gato! Brincadeira, é que eu usei o nome do gato de nick. A Pixel pra mim **é uma mulher na luta pra arrumar seu espaço no mundo**, ansiosa, mas esforçada, não muito paciente, mas teimosa. Nerd de carteirinha e mto apaixonada por tecnologia e ciencia.

## Quem é Pixl Rose para o mundo?
Uma gotinha de água no Oceano Atlântico.

## O quê a Pixl Rose faz atualmente?
Estuda desenvolvimento pra Web, faz uns corre pra pagar boletos, cuida de gato e estuda mais um pouco

## O quê é tecnologia para você?
Inovação, comunicação, um facilitador, mas como tudo na vida, se usada de maneira errada pode ser um baita de um complicador.

## Como a tecnologia mudou a sua vida?
Foi o meu primeiro grande interesse, primeira paixão, me colocou **no caminho que seguiria pro resto da vida.**

## Qual foi seu primeiro contato com tecnologia?
Com doze anos, meus primos tinham um computador, um IBM PC XT de tela verde, que eles usavam pra jogar strip poker. Eu sentava na frente do computador desligado e digitava vários textos.

## O quê são comunidades para você?
Hoje em dia **são meu chão**, minha estabilidade, onde eu encontro meus amigos, ajuda técnica ou não, me divirto e **divido as frustrações e angústias do dia a dia.**

## Como as comunidades mudaram a sua vida? 
Eu aprendi a me comunicar melhor, avancei muito mais rápido na carreira fazendo contatos e dividindo aprendizados, conheci pessoas completamente diferentes que abriram a minha cabeça pro tamanho do mundo lá fora.

## Quais comunidades você participa?
Ativamente, a [Caverna do Patocórnio](https://caverna.live/) e [Feministech](https://feministech.github.io/), mas estou sempre de olho em várias outras.

## Quais são os seus sonhos?
Me encontrar, solidificar minha profissão, **dar um chute na síndrome do impostor**, fazer algo de relevante, **nem que seja relevante pra uma pessoa só.**

## Redes

[Twitter](https://twitter.com/pixlrose/)
[Instagram](https://www.instagram.com/pxlrose/)
[Twitch](https://twitch.tv/pixlrose)
AE.STUDIO - JOIN US!
Tags: hiring
Published: 2022-04-07 20:32:25

## About Us

AE Studio | LA Office | Multiple Roles | Full-Time | Remote | ae.studio

## About The Opportunity

We are a development, data science and design studio that works closely with founders and executives to create custom software and machine learning solutions.

## Skill & Qualifications

We are hiring top notch professionals passionate about software development, data science, design or product management to work with our amazing team creating human agency increasing software!

## How To Apply

Full descriptions: https://ae.studio/join-us

\_Please feel free to leave questions in the comments section.
Best Pens and Projects on CodePen (#2)
Tags: javascript, codepen, css, html
Published: 2022-04-07 20:02:57

Hi everyone...

I just back again with the 2nd part of [the Best Pens and Projects on CodePen series](https://dev.to/md3bm/series/17578), Which contains a huge and distinctive content of codes, templates, ready-made projects for front-ends, and various web elements.

You can check the previous parts of the Best Pens and Projects on CodePen series below:

1. [Best Pens and Projects on CodePen (#1)](https://dev.to/md3bm/best-pens-and-projects-on-codepen-1-1dil)

> Note: All ownership and reuse rights are reserved for their respective owners.

Let's start .. -->
<hr>
## Top Pens and Projects on CodePen (Part 2)

### auto dark mode with SVG blend modes

{% codepen https://codepen.io/patrickhill/pen/gORWmZr %}

### Context menu with Feather icons

{% codepen https://codepen.io/havardob/pen/YzwzQgm %}

### Dreaming of Jupiter - Three.js

{% codepen https://codepen.io/isladjan/pen/zYqLxeG %}

### Accordion FAQ Menu By @itsrehanraihan 

{% codepen https://codepen.io/itsrehanraihan/pen/GRyNzxZ %}

### augmented-ui social media picture-of-code thing

{% codepen https://codepen.io/propjockey/pen/dyVMgBg %}

### 3D Carousel

{% codepen https://codepen.io/ykadosh/pen/ZEJLapj %}

### #Codevember 10 - Musical Particles

{% codepen https://codepen.io/seanfree/pen/RorjpB %}

### Night & Day

{% codepen https://codepen.io/ste-vg/pen/oNgrYOb %}

Read also: The best [ready-made HTML codes](https://www.md3bm.com/2024/02/best-pens-on-codepen-p7.html) | CSS | Javascript on CodePen (Part 7)
### Order button animation

{% codepen https://codepen.io/aaroniker/pen/oNgPOwo %}

### Music Player 2.0
An amazing and beautiful music player in phone mockup.

{% codepen https://codepen.io/emilcarlsson/pen/WdRRMX %}

### Side Sliding Menu CSS

{% codepen https://codepen.io/EduardL/pen/jObzJB %}

### Tiles with animated : hover

{% codepen https://codepen.io/chrisgrabinski/pen/nrpGRG %}

### Animated Tab Bar v.2

{% codepen https://codepen.io/abxlfazl/pen/OJbEbxL %}

### Codepen Shortcut List

{% codepen https://codepen.io/iiCe89/pen/gMYVYQ %}

### Instagram re-design

{% codepen https://codepen.io/TurkAysenur/pen/qeNvRM %}

### CSS Only Playground

{% codepen https://codepen.io/ekrof/pen/YqmXdQ %}

### Easy Ionic Side Menu Transitions

{% codepen https://codepen.io/jcoulterdesign/pen/jWWroX %}
<hr>
Read also: [The best HTML, CSS and JS codes ready on CodePen (Part 6)](https://www.md3bm.com/2023/10/best-pens-and-projects-on-codepen-p6.html)
<hr>
## Last words

This was the 2nd part of the Top Pens and Projects on CodePen series presented by md3bm, which will be followed by other parts that will include Pens codes and awesome and distinctive ready-made projects for inspiration and to be used in developing your web projects.
April 7th, 2022: What did you learn this week?
Tags: weeklylearn, weeklyretro, discuss
Published: 2022-04-07 20:18:30

It's that time of the week again. So wonderful devs, what did you learn this week? It could be programming tips, career advice etc.

<center>

![David from Schitt's Creek saying "This is a teachable moment for all of us!"](https://media.giphy.com/media/Q8rwlNTcDAU3MuUzd7/giphy-downsized-large.gif)
</center>

Feel free to comment with what you learnt and/or reference your TIL post to give it some more exposure.

{%tag todayilearned %}
Let's say "Hello World" with Lambda Function URLs
Tags: aws, serverless
Published: 2022-04-07 20:17:34

## TL;DR
Briefly tested Lambda Function URLs that AWS announced yesterday.

## Introduction
Hi everyone! I am Kosuke who is working as a Product Owner based in Japan and one of the members of [AWS Community Builders](https://aws.amazon.com/jp/developer/community/community-builders/) for Serverless.

My SNS are;
- Twitter -> [@coosuke](https://twitter.com/coosuke)
- LinkedIn -> [Kosuke Enomoto](https://www.linkedin.com/in/kosuke-enomoto/)
- Blog(Japanese) -> [note](https://note.com/coosuke/)

## What is "Lambda Function URLs" ?
On Apr/06/2022 AWS announced a new feature that makes it easier to invoke functions through an HTTPS endpoint as a built-in capability of the AWS Lambda service. You can see details at AWS blog.
[Announcing AWS Lambda Function URLs: Built-in HTTPS Endpoints for Single-Function Microservices](https://aws.amazon.com/jp/blogs/aws/announcing-aws-lambda-function-urls-built-in-https-endpoints-for-single-function-microservices/)

## Let's say hello with Lambda Function URLs!!
I briefly tested that new feature within a half hours.
Here are the procedures.

1. Log on to AWS Console and go on to AWS Lambda > Functions.
1. Click "**create function**" on the upper right.
![1st step: Click create function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5zgdouhgari7vaymd290.png)
1. Choose "**Author from scratch**"
![2nd step: choose how to create the function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bi9bl11eeeeapi35awub.png) 
1. name the **Function name**(_helloWorldUrlTest_), choose **Runtime**(_Node.js 14.x_) and **Architecture**(*x86_64*). Permission can stay as default(as chosen *Create a new role with basic Lambda permissions*).
![3rd step: basic settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/scofohwkc7wgld15qnil.png) 
1. Open **Advanced settings**, check **Enable function URL** and you will see some more settings, **Auth type** to *NONE* and check **Configure cross-origin resource sharing(CORS)**.
![4th step: Advanced settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqf9fz6y04lrokhz7qzr.png)
1. Click **Create function** button on the bottom. 
1. Here you created the function! 
![5th step: Function created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8y3oovr1nj13pj8cdhm.png) 
1. You can see the function URL. Click it and you will see "**Hello from Lambda!**" That's it!
![6th step: test](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sd76ezkkv6g03esmcnry.png)

## Closing remarks
It took only just a few minutes to see "Hello world" in the browser.
The codes just returns simple JSON including HTTP status code 200 and body "Hello from Lambda!". 
```
{
  "statusCode": 200,
  "body": "\"Hello from Lambda!\""
}
```
The [AWS blog](https://aws.amazon.com/jp/blogs/aws/announcing-aws-lambda-function-urls-built-in-https-endpoints-for-single-function-microservices/) offers sample codes to deep dive into the function URLs feature, so you just build and test it! 

Thank you very much for reading! See you next time!!
how on earth does this work
Tags: javascript, node, watercooler, funny
Published: 2022-04-07 20:06:45

was reading 
{% embed https://t.me/programmerjokes/2198 %}
so i tested this in the terminal via node:
```js
([]+![])[![]+1].repeat(100).toUpperCase()
```
and it worked!?!?!?!??!
![image of results](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfqxs715qt581h9s9ejg.png)

probably a dumb question but how does that work?
pardon my javascript , but it looks like a mess of arrays repeated 100 times in uppercase

this is dumb.

and ridiclous.

mystifying.

but also kind funny.
Create tags in React
Tags: react, reactnative, webdev, beginners
Published: 2022-04-07 19:56:46

Tags are the keywords associated to a piece of information. Tags are often used on social websites, email systems, blogs where users can upload their own content. They are separated by comma or enter. Here we will create tags in react applications with the help of [react-tag-input component](https://www.npmjs.com/package/react-tag-input).

## Installation

```ssh
npm install --save react-tag-input
```

Now, we have **&lt;ReactTags /&gt;** component which we can use in our class or functional component. Here, we are using this in our App Component.

## Create tags in React

```typescript
import React, { useState } from 'react';
import { render } from 'react-dom';
import { WithContext as ReactTags } from 'react-tag-input';

const KeyCodes = {
  comma: 188,
  enter: 13
};

const delimiters = [KeyCodes.comma, KeyCodes.enter];

const App = () => {

  const [tags, setTags] = React.useState([
    { id: 'USA', text: 'USA' },
    { id: 'India', text: 'India' },
    { id: 'Vietnam', text: 'Vietnam' },
    { id: 'Turkey', text: 'Turkey' }
  ]);

  const handleDelete = i => {
    setTags(tags.filter((tag, index) => index !== i));
  };

  const handleAddition = tag => {
    setTags([...tags, tag]);
  };

  const handleDrag = (tag, currPos, newPos) => {
    const newTags = tags.slice();

    newTags.splice(currPos, 1);
    newTags.splice(newPos, 0, tag);

    setTags(newTags);
  };

  const handleTagClick = index => {
    console.log('The tag at index ' + index + ' was clicked');
  };

  const suggestions = [
	  {
	    id: 'India',
	    text: 'India'
	  },
	  {
	    id: 'USA',
	    text: 'USA'
	  }
  ];

  return (
    <div className="app">
      <h1> React Tags Example </h1>
      <div>
        <ReactTags
          tags={tags}
          suggestions={suggestions}
          delimiters={delimiters}
          handleDelete={handleDelete}
          handleAddition={handleAddition}
          handleDrag={handleDrag}
          handleTagClick={handleTagClick}
          inputFieldPosition="bottom"
          autocomplete
        />
      </div>
    </div>
  );
};

render(<App />, document.getElementById('root'));
```
You can read about props of [react-tag-input component in detail here](https://www.npmjs.com/package/react-tag-input).

---

Please like share subscribe and give positive feedback to motivate me to write more for you.

For more tutorials [please visit my website](https://www.w3courses.org/tutorials/).

Thanks:)
Happy Coding:)
Back to Back #11 - Back-end news by SFEIR
Tags: newsletter, french, backend, cfp
Published: 2022-04-07 19:50:50

_Hello, world ! En plus de la sélection d'articles venant des Sfeiriens, retrouvez les dernières infos sur les évènements tech en France et la sélection d’article de notre Speakeuse invitée !_ 

---

### 🔍️ Learning Go by examples

Nous avons eu le privilège de recevoir [Aurélie Vache](http://scraly.com/), DevRel chez OVH Cloud, qui nous a parlé de Golang à travers son talk _Common tips & mistakes en Go - et comment les résoudre_. On vous partage sa série d'articles sur ce langage. Une bonne base pour bien démarrer sur Go ! Merci encore Aurélie pour ton partage et ta bonne humeur 👍

{% embed https://dev.to/aurelievache/learning-go-by-examples-introduction-448n %}

### ☕ [Java 18 : le point sur les nouveautés](https://k49.fr.nf/java-18-le-point-sur-les-nouveautes)

Dans cet article, Anthony nous donne un aperçu des nouveautés de Java 18, qui est sorti fin mars. On trouve dans ces nouveautés la dépréciation de la méthode `finalize()`, le tag `@snippet` pour la Javadoc ou encore une nouvelle version de la preview pour le pattern matching des switch.

### 🪝 [Google Calendar Webhooks with Node.js](https://fusebit.io/blog/google-calendar-webhooks)

L'API de Google Calendar propose des webhooks. Ces webhooks sont utilisables pour, par exemple, mettre à jour un statut sur Slack ou envoyer un message sur Discord quand un évènement est modifié. [Rubén Restrepo](https://twitter.com/degrammer) nous propose un tutoriel pour attraper des événements spécifiques et déclencher des actions.

### 📺 .NET Microservices

Voici un cours complet en ligne sur la création de microservices en .NET. Différentes notions sont abordées comme la création d'API REST, le déploiement des services sur un cluster Kubernetes ou encore ou une messagerie asynchrone avec RabbitMQ. Bon visionnage ! 

{% embed https://www.youtube.com/watch?v=DgVjEo3OGBI %}

---

### CFP et évènements
Plusieurs évènements tech ont annoncé leur retour en 2022 et leurs _calls for papers_ sont ouverts ! C’est le moment de proposer vos talks pour :
- [Voxxed Days](https://cfp-voxxed-lux.yajug.org/), CFP ouvert jusqu'au 10/04
- [DevFest Nantes](https://conference-hall.io/public/event/CfucIjaXxrZThJE0POR3), CFP ouvert jusqu'au 19/06 

---

_Merci à la communauté back-end ! On se retrouve fin avril, dernier mercredi du mois._
Understanding Spring4Shell RCE from an engineer’s perspective
Tags: security, webdev, java
Published: 2022-04-07 18:16:11


![Software-developer-holds-the-pen-pointing-to-the-computer-screen-and-is-analyzing-the-code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8w2yeatvonx8hyqfw1u.jpeg)

## What happened?

On March 29, 2022, A very old RCE (remote code execution) loophole tracked as CVE-2010-1622 was exposed in a series of Tweets. It affects most java projects using JDK 9+. This loophole enables attackers to exploit the server by executing a command on a server carried in a HTTP request.

## Who should worry about this vulnerability?

If your project meets all conditions below, then you should take a serious look into this:
- **JDK 9+**
- Imported **spring-webmvc** dependency
- Deployed as **WAR** but not JAR
- **Apache Tomcat** as the Servlet container (the only container confirmed exploit currently)

## How did this happen?

Before explaining more details, let’s first start with a simple API defined in SpringMVC controller.

```
@Controllerpublic class DemoController {

    @PostMapping("/animals")
    @ResponseBody
    public Map<String, Object> importAnimalIntoZoo(Animal animal) {
        HashMap<String, Object> response = new HashMap<>();
        response.put("data", animal);
        return response;
    }
}
```

[read more](https://www.datawiza.com/blog/technical/understanding-spring4shell-rce-from-an-engineers-perspective/)...
Minimum Swaps TO make binary String Alternating
Tags: java, algorithms, leetcode
Published: 2022-04-07 19:28:16


 <u>**Examples:</u>
Input: s = "111000"
Output: 1
Input: s = "010"
Output: 0


/* Here we simply need to check the below 4 cases:
1.if(no of 0s > no of 1s)
  all odd position should be 0 if not count++;
2.if(no of 0s < no of 1s)
  all odd position should be 1 if not count++;
3.if(Math.abs(0s-1s)>1)
  return -1;// alternating not possible
4.if(both are equal in no)
  return minimum of(both the arrangements);*/


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/33yrsc5j9dhhjvjf8a9p.jpg)


`class Solution {
    public int count(char f, String s){
        int temp=0;
        for(int i=0;i<s.length();i+=2){
            if(s.charAt(i)==f) temp++;
        }
        return temp;
    }
    public int minSwaps(String s) {
        int z=0,o=0;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='0')
                z++;
            else o++;
        }
        if(z-o==1){
            return z-count('0',s);
        }
        else if(o-z==1){
            return o-count('1',s);
        }
        else if(o-z==0)
            return Math.min(count('1',s),count('0',s));
        else return -1;
    }
    
}`
What's an Open Source Project You Think Deserves More Support?
Tags: discuss, opensource
Published: 2022-04-07 18:46:51

There are many open source projects out there and a lot of them act as alternatives for popular commercial platforms. Regardless of what functionalities they provide, they're powered by people who believe in the open source community and want to work with it to create great products for everyone to use.

What are some open source projects do you guys think developers should give more support too? Or what are just some of your favorites?

I personally have lots of love for [Strapi](https://strapi.io). I know they're popular enough at this point but I still love giving them a shout out when possible 🫶🏻
Can't Decide on a Backend
Tags: backend, nocode, database, headlesscms
Published: 2022-04-07 18:31:24

I'm trying to build an application that will have a web application and also mobile applications (iOS and Android) eventually.

I don't know anything about backends, and I've seen different nocode / low code backend solutions, as well as headless CMS.

Can someone explain the difference between some of these no code backend solutions e.g. BudiBase and headless CMS e.g. GraphCMS ?

Also, can I use any of these as a centralised database that will feed both the web and mobile, or should I just stick with something more traditional like Firebase?

It doesn't have to be the specific examples I gave, but there are so many options, I don't know what to pick.

I'm planning to build the web front end with WeWeb (weweb.io), or possibly Bubble.

Thanks.
List vs Tuple - When To Use Each?
Tags: python, tutorial, programming, beginners
Published: 2022-04-07 18:16:47

In Python, **lists** and **tuples** are two built-in data types. Conceptually they are very similar, but there is some **difference**.

First, the lists are **mutable**. This means that once you have defined a list, you **can** modify it.

For example,

```python
>>> l = ['a', 'b', 'c']
>>> l[1] = 'x'
>>> print(l)
['a', 'x', 'c']
```

You can modify the list without any problems.

On the contrary, tuples are **immutable**. After creating a tuple, you **cannot** modify it. If you try to modify a tuple you will get an error, as shown in the following example:

```python
l = ('a', 'b', 'c')
l[1] = 'x'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
```

Tuples have an advantage over lists. They are **more memory efficient** and **time efficient** than the lists. This means that using a tuple to store a set of items will require less memory than using a list to store the same set of items. Also, creating a tuple requires less time than creating a list.

The following table summarizes the differences:

| Lists                  | Tuples                 |
| ---------------------- | ---------------------- |
| Defined using square brackets | Defined using rounded brackets |
| :heavy_check_mark: Lists are mutable      | :x: Tuples are immutable    |
| :x: Use more memory        | :heavy_check_mark: Use less memory |
| :x: Slower        | :heavy_check_mark: Faster        |

## Conclusions

Tuples are more **memory** and **time efficient** but cannot be modified. 

Therefore, if you have data that don't need to be changed, you should use tuples. Instead, if you need to change data you are forced to use lists.
Not sure how to get involved and become an open source contributor? It can be as easy as saying hello!
Tags: opensource, python, community, contributorswanted
Published: 2022-04-07 18:08:16

Found-CEO, Didier Lopes, has a special place in his heart for Python, Open Source, Fintech, and Memes. How about an open-source and finance-themed meme generator dashboard for Jupyter Notebooks?

We're always looking to incorporate the open source community contributions. No contribution is too small! 

Say hello on our Community Discord Server: https://discord.com/invite/Up2QGbMKHY

Checkout the repository: https://github.com/OpenBB-finance/OpenBBTerminal

![https://openbb.co](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwvdn09936qk5qnl2cb9.png)

![https://openbb.co](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bz8nmvlj4j2knaej38nd.png)

![https://openbb.co](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gao1lnswybw008oiqoy2.png)