Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Reshape DataFrame¶
import pandas as pd
import numpy as npdf1 = pd.DataFrame({"x": [1, 2, 3], "y": [5, 4, 3]})
df1Loading...
df2 = pd.DataFrame({"x": [0, 0, 3000], "y": [78, 4, 3]})
df2Loading...
Concate Rows¶
You can use both the DataFrame.append (returns a new data frame rather than in-place) and pandas.concat to concate rows of data frames.
pandas.concat is recommended when you want to concate rows of multiple data frames.
df1.append(df2, ignore_index=True)Loading...
df1Loading...
pd.concat([df1, df2], ignore_index=True)Loading...
Repeat rows of a DataFrame.
pd.concat([df1] * 3, ignore_index=True)Loading...
Concate Columns¶
pd.concat([df1, df2], axis=1)Loading...
pd.concat([df1, df2], ignore_index=True, axis=1)Loading...