In [1]:
import pandas as pd
import numpy as np
In [2]:
df_homo = pd.DataFrame({'a': [0, 1, 2], 'b': [3, 4, 5]})
print(df_homo)
In [3]:
print(df_homo.dtypes)
In [4]:
df_homo_slice = df_homo.iloc[:2]
print(df_homo_slice)
In [5]:
print(np.shares_memory(df_homo, df_homo_slice))
In [6]:
print(df_homo_slice._is_view)
In [7]:
df_homo_list = df_homo.iloc[[0, 1]]
print(df_homo_list)
In [8]:
print(np.shares_memory(df_homo, df_homo_list))
In [9]:
print(df_homo_list._is_view)
In [10]:
print(df_homo['a'] < 2)
In [11]:
df_homo_bool = df_homo.loc[df_homo['a'] < 2]
print(df_homo_bool)
In [12]:
print(np.shares_memory(df_homo, df_homo_bool))
In [13]:
print(df_homo_bool._is_view)
In [14]:
s_homo_scalar = df_homo.iloc[0]
print(s_homo_scalar)
In [15]:
print(np.shares_memory(df_homo, s_homo_scalar))
In [16]:
print(s_homo_scalar._is_view)
In [17]:
s_homo_col = df_homo['a']
print(s_homo_col)
In [18]:
print(np.shares_memory(df_homo, s_homo_col))
In [19]:
print(s_homo_col._is_view)
In [20]:
df_homo_col_multi = df_homo[['a', 'b']]
print(df_homo_col_multi)
In [21]:
print(np.shares_memory(df_homo, df_homo_col_multi))
In [22]:
print(df_homo_col_multi._is_view)
In [23]:
df_homo.iat[0, 0] = 100
print(df_homo)
In [24]:
print(df_homo_slice)
In [25]:
print(df_homo_list)
In [26]:
print(df_homo_bool)
In [27]:
print(s_homo_scalar)
In [28]:
print(s_homo_col)
In [29]:
print(df_homo_col_multi)
In [30]:
df_hetero = pd.DataFrame({'a': [0, 1, 2], 'b': ['x', 'y', 'z']})
print(df_hetero)
In [31]:
print(df_hetero.dtypes)
In [32]:
df_hetero_slice = df_hetero.iloc[:2]
print(df_hetero_slice)
In [33]:
print(np.shares_memory(df_hetero, df_hetero_slice))
In [34]:
print(df_hetero_slice._is_view)
In [35]:
df_hetero_slice2 = df_hetero.iloc[:2, 0:]
print(df_hetero_slice2)
In [36]:
print(np.shares_memory(df_hetero, df_hetero_slice2))
In [37]:
print(df_hetero_slice2._is_view)
In [38]:
df_hetero_list = df_hetero.iloc[[0, 1]]
print(df_hetero_list)
In [39]:
print(np.shares_memory(df_hetero, df_hetero_list))
In [40]:
print(df_hetero_list._is_view)
In [41]:
df_hetero_bool = df_hetero.loc[df_hetero['a'] < 2]
print(df_hetero_bool)
In [42]:
print(df_hetero_bool._is_view)
In [43]:
print(df_hetero_bool._is_view)
In [44]:
s_hetero_scalar = df_hetero.iloc[0]
print(s_hetero_scalar)
In [45]:
print(np.shares_memory(df_hetero, s_hetero_scalar))
In [46]:
print(s_hetero_scalar._is_view)
In [47]:
s_hetero_col = df_hetero['a']
print(s_hetero_col)
In [48]:
print(np.shares_memory(df_hetero, s_hetero_col))
In [49]:
print(s_hetero_col._is_view)
In [50]:
df_hetero_col_multi = df_hetero[['a', 'b']]
print(df_hetero_col_multi)
In [51]:
print(np.shares_memory(df_hetero, df_hetero_col_multi))
In [52]:
print(df_hetero_col_multi._is_view)
In [53]:
df_hetero.iat[0, 0] = 100
print(df_hetero)
In [54]:
print(df_hetero_slice)
In [55]:
print(df_hetero_slice2)
In [56]:
print(df_hetero_list)
In [57]:
print(df_hetero_bool)
In [58]:
print(s_hetero_scalar)
In [59]:
print(s_hetero_col)
In [60]:
print(df_hetero_col_multi)