-1

Sample of my existing script:

# import python libraries
import pandas as pd

# declare file name as 'infileName' & 'outfileName'
infileName="FFH069.3-W02_dielist.csv"
outfileName="Import_FFH069.3-W02_dielist.csv"

# load the data
data = pd.read_csv(infileName)

# convert to a DataFrame
df = pd.DataFrame(data)

# remove unneeded columns
df.drop(columns=["x_center","y_center","x_extent","y_extent"], axis=1, inplace=True)

# rename the infilename columns to match Object Attributes
df.rename(columns={'layout_id':'Design'}, inplace = True)

# insert new columns to match the Object Attributes
df.insert(0,"Wafer + Die ID", "FFH069.3-W02-")
df.insert(1,"Chip Preference", "Primary")

# print the infileName head to validate changes
print(df.head())

  Wafer + Die ID Chip Preference             Design  x_die y_die
0  FFH069.3-W02-         Primary  DS-CHR-0009-01-01      2     0
1  FFH069.3-W02-         Primary  DS-CHR-0008-01-02      3     0
2  FFH069.3-W02-         Primary  DS-CHR-0009-01-01      4     0
3  FFH069.3-W02-         Primary      DS-TLS-001-D6      5     0
4  FFH069.3-W02-         Primary  DS-CHR-0008-01-02      1     1

I have made attempts using the concat function to combine 'Wafer + Die ID' + 'x_die' + '.' + 'y_die' and read through other options, but am not sure which is best served, nor how to implement.

Desired Output:

     Wafer + Die ID Chip Preference             Design  x_die y_die
0  FFH069.3-W02-2.0         Primary  DS-CHR-0009-01-01      2     0
1  FFH069.3-W02-3.0         Primary  DS-CHR-0008-01-02      3     0
2  FFH069.3-W02-4.0         Primary  DS-CHR-0009-01-01      4     0
3  FFH069.3-W02-5.0         Primary      DS-TLS-001-D6      5     0
4  FFH069.3-W02-1.1         Primary  DS-CHR-0008-01-02      1     1
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Welcome to Stack Overflow! So, you don't know how to do this at all? Then don't worry about "the most efficient" way yet. Figure out **a** way to do it, then think about optimizing it *if it's not fast enough*. What options have you looked at exactly? Cause `pd.concat` doesn't concatenate strings. Have you seen this for example? [String concatenation of two pandas columns](/q/11858472/4518341). The simplest option is [this one](/a/74160943/4518341). – wjandrea Aug 11 '23 at 18:17
  • To give some more advice: Check out [How to ask a good question](/help/how-to-ask), which has tips like including what research you've done and making a [mre]. I mean, if it's not relevant how you're loading the data or what's in the other columns, then you don't need to show us. For specifics, see [How to make good reproducible pandas examples](/q/20109391/4518341). You can [edit] if needed. – wjandrea Aug 11 '23 at 18:17

0 Answers0