小编Sel*_*imi的帖子

将数据帧中的字符串行替换为其他数据帧panda中的相应字

我有一个有1列的df

     List
 0   What are you trying to achieve
 1   What is your purpose right here
 2   When students don’t have a proper foundation
 3   I am going to DESCRIBE a sunset
Run Code Online (Sandbox Code Playgroud)

我有其他数据帧df2

它有2列

    original       correct
0     are          were
1     sunset       sunrise
2     I            we
3     right        correct
4     is           was
Run Code Online (Sandbox Code Playgroud)

我想在我的df中替换这样的单词,这些单词出现在original我的df2列中,并替换为correct列中的相应单词.并将新字符串存储在其他数据帧中df_new

是否可以不使用循环和迭代,只使用普通的熊猫概念?

即我df_new应该包含.

     List
 0   What were you trying to achieve
 1   What was your purpose correct here
 2   When students don’t …
Run Code Online (Sandbox Code Playgroud)

python pandas

6
推荐指数
1
解决办法
386
查看次数

链接列表段错误

我遇到了分段错误,我不知道问题出在哪里.

#include "stdio.h"
#include "stdlib.h"

struct node {
    int data;
    struct node *next;
    };
    struct node *head = NULL;
    struct node * curr;
    struct node * newNode;

void createList(){

    int data,n , i ;
    scanf("%d",&n);
    for (i = 0 ; i < n ;i++){
        scanf("%d",&data);
        curr = head;
        newNode = (struct node*)malloc(sizeof(struct node));
        newNode->data=data;
        newNode->next=NULL;
        if ( curr == NULL){
            head = newNode;
        }else
            while (curr->next != NULL){
                curr = curr->next;
            }
            curr->next = newNode;
    }

}

int main(int argc, …
Run Code Online (Sandbox Code Playgroud)

c linked-list

0
推荐指数
1
解决办法
51
查看次数

标签 统计

c ×1

linked-list ×1

pandas ×1

python ×1