Home > other >  About pandas processing data, how to extract a column part Numbers
About pandas processing data, how to extract a column part Numbers

Time:09-21

As title, with pandas read. CSV file data, including a list of the ID attribute contains 6 digits, I'd like to replace for the ID attribute values in the column value of the top two, could you tell me how to do this?
In addition, I. CSV data originally no index, the first column is the label column, the diagram below:

But the deal with much more data after the front two columns with pandas index value? Is this can delete?

CodePudding user response:

It has great god ~

CodePudding user response:

Your description and stick figure didn't you see it is, don't understand what you are asking

CodePudding user response:

refer to the second floor uiuiy1 response:
your description and stick figure didn't you see it is, don't understand what you are asking what

Is there are two problems:
1. The first chapter of the second column is the ID attribute of the picture, I only focus on the first two Numbers, in the picture is number 17, how can I get the original ID attribute corresponds to the six value replacement for two?
2. I deal with the data with the pandas and then deposited in the. CSV file, but I found these. CSV file for more than two columns in front of the index value, just like the first picture is the original data, the first column is the label, the second column is the ID, I merge the other. After CSV, got the second picture, the first two columns are the index of the new generation, and the third column is my label, the fourth column is the ID, and so on, these index, how to delete? Want to drop or del no column name,

CodePudding user response:

With the open (' 1. TXT ', 'r') as r:
Js=[i. trip (). The split () ', 'for I r] in


For I in js:
I [1]=I [1] [2-0]

Print js

CodePudding user response:

Df=pd read_csv ('../input/xx. CSV ', the header=None)
Df [1]=df [1]//10000
Df. To_csv ('../output/xx. CSV ', the index=False, the header=False)

Not to, under reference

CodePudding user response:

Thank you two upstairs, I wait for the next try ~

CodePudding user response:

Generated, and the index=False, it will be generated index
  • Related