Append Additional Information(data) to Dataframe Column Values

45 Views Asked by At

I have a dataframe that looks like this:

Filename        Label
Mont_01_015_00  IDL 
Mont_01_016_00  NEG 

There are 18,000+ files and I am looking at append (.wav) to the filenames so that it will look like this:

Filename            Label
Mont_01_015_00.wav  IDL
Mont_01_016_00.wav  NEG

I have tried several dataframe.append options without success. I am relatively new to this so I will appreciate your help. Thanks.

2

There are 2 best solutions below

1
Boskosnitch On
df.Filename = df.Filename+'.wav'

ex:

>>> df
   A  B  C  D
0  e  h  b  a
1  h  c  e  i
2  j  h  f  d
3  a  f  i  a
4  e  d  g  a
5  d  e  j  j
6  d  b  j  g
7  b  g  f  c
8  d  b  a  c
9  h  d  e  a
>>> df.A = df.A+'.wav'
>>> df
       A  B  C  D
0  e.wav  h  b  a
1  h.wav  c  e  i
2  j.wav  h  f  d
3  a.wav  f  i  a
4  e.wav  d  g  a
5  d.wav  e  j  j
6  d.wav  b  j  g
7  b.wav  g  f  c
8  d.wav  b  a  c
9  h.wav  d  e  a
0
Pygirl On

try:

df['Filename'] = df['Filename'].map('{}.wav'.format)