SA12
SA12

Reputation: 318

Copy a pandas.series to another

I have two pandas series as below:

a = pd.Series([1,2,3,4,5])
b = pd.Series(['NaN','NaN','NaN','NaN','NaN'])

and I want to copy/replace a to b. namely, b= [1,2,3,4,5].

Upvotes: 0

Views: 35

Answers (1)

Antoine Dubuis
Antoine Dubuis

Reputation: 5314

You can simply use:

b = a.copy()

you can verify that both series a and b are equal with:

pd.testing.assert_series_equal(a, b)

Upvotes: 2

Related Questions