How can I avoid using the copy of the dictionary provided when creating the Pandas DataFrame?
>>> a = np.arange(10) >>> b = np.arange(10.0) >>> df1 = pd.DataFrame(a) >>> a[0] = 100 >>> df1 0 0 100 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 >>> d = {'a':a, 'b':b} >>> df2 = pd.DataFrame(d) >>> a[1] = 200 >>> d {'a': array([100, 200, 2, 3, 4, 5, 6, 7, 8, 9]), 'b': array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])} >>> df2 ab 0 100 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9
If I create a dataframe only from a, then changes to are reflected in df (and vice versa).
Is there any way to make this work when supplying a dictionary?
source share