Answers for "dataframe add a column with same value python"

2

add two column values of a datframe into one

df["period"] = df["Year"] + df["quarter"]
Posted by: Guest on May-10-2020
0

add multiple columns to dataframe if not exist pandas

cols = ['B','C','D']

df = df.reindex(df.columns.union(cols, sort=False), axis=1, fill_value=0)
print (df)
   A  B  C  D
0  1  2  3  0
1  4  4  5  0
2  1  2  3  0
3  4  4  6  0
Posted by: Guest on April-18-2021

Code answers related to "dataframe add a column with same value python"

Python Answers by Framework

Browse Popular Code Answers by Language