Dataframe Two csv column dict conversion questions.

Asked 1 years ago, Updated 1 years ago, 109 views

I wrote the title like that, but I didn't know how to express it, so I wrote it over and over.

There are two csv files. For example, the subject code with code and test subjects (Korean, English, math) and the csv file There is a score.csv that stores the score per subject.

ex)Subject code.csv
Code // Test subject
1 Korean
2 English 3 Math

ex)Score.csv
code // score // name
170 Hong Gil-dong
178 Hong Gil-soon
195 Hong Gil-hak
290 Hong Gil-dong 268 Hong Gil-soon
285 Hong Gil-hak

At this time, I would like to change the code of the score.csv to a test subject.
ex) result.csv
Korean 70 Hong Gil-dong Korean 78 Hong Gil-soon Korean 95 Hong Gil-hak 90 Hong Gil Dong in English English 68 Hong Gil-soon English 85 Hong Gil-hak

There are only a few examples, but there are almost 500,000 data, so I don't think I can change it every day I definitely learned it, but I can't remember it and I don't know how to search, so I'm asking you because I'm tired of searching

dataframe pandas column

2022-09-21 10:01

1 Answers

import pandas as pd
score.merge(code)

You can calculate join with code, which is the common column of subject code and score.


2022-09-21 10:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.