How do i repeat a string in a new column based on the length of the dataframe in pandas?

Viewed 276

I have a df as:

x_data         y_data
2.4             3.6
6.8             5.6
7.9             2.5
7.0             6.9

I want to add a new column with which has a string repeated.

My final output is:

x_data         y_data      DataType
2.4             3.6        Acceleration
6.8             5.6        Acceleration
7.9             2.5        Acceleration
7.0             6.9        Acceleration
1 Answers

You can just assign a string to the column you want to contain the repeated string.

Like:

df['DataType'] = 'Acceleration'
Related