Vectorised method to append dataframe rows to columns and vice-versa
问题 My dataframe is as follows: df = pd.DataFrame({'a': {'d': 1, 'e': 0, 'f': 1, 'g': 1}, 'b': {'d': 0, 'e': 0, 'f': 0, 'g': 1}, 'c': {'d': 0, 'e': 1, 'f': 1, 'g': 0}}) which gives: >>> df a b c d 1 0 0 e 0 0 1 f 1 0 1 g 1 1 0 For every row in the dataframe, I would like to add a new column of 0 s , and for every column in the dataframe, I would like to add a new row of 0 s. I've attempted to solve this problem so far in the following way: edges = df.columns for i in df.index: df[i] = [0 for _ in