2

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.

Gee
  • 21
  • 1
  • Does this answer your question? [add a string prefix to each value in a string column using Pandas](https://stackoverflow.com/questions/20025882/add-a-string-prefix-to-each-value-in-a-string-column-using-pandas) – AlexisG Mar 10 '21 at 12:54

2 Answers2

1
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
Boskosnitch
  • 774
  • 3
  • 8
1

try:

df['Filename'] = df['Filename'].map('{}.wav'.format)
Pygirl
  • 12,969
  • 5
  • 30
  • 43