In [1]:
import pandas as pd
import numpy as np
In [2]:
a = np.array([[0, 1], [2, 3], [4, 5]])
print(a)
In [3]:
df = pd.DataFrame(a)
print(df)
In [4]:
print(np.shares_memory(a, df))
In [5]:
print(df._is_view)
In [6]:
a[0, 0] = 100
print(a)
In [7]:
print(df)
In [8]:
a_str = np.array([['a', 'x'], ['b', 'y'], ['c', 'z']])
print(a_str)
In [9]:
df_str = pd.DataFrame(a_str)
print(df_str)
In [10]:
print(np.shares_memory(a_str, df_str))
In [11]:
print(df_str._is_view)
In [12]:
a_str[0, 0] = 'n'
print(a_str)
In [13]:
print(df_str)
In [14]:
df_homo = pd.DataFrame({'a': [0, 1, 2], 'b': [3, 4, 5]})
print(df_homo)
In [15]:
print(df_homo.dtypes)
In [16]:
a_homo = df_homo.values
print(a_homo)
In [17]:
print(np.shares_memory(a_homo, df_homo))
In [18]:
df_homo.iat[0, 0] = 100
print(df_homo)
In [19]:
print(a_homo)
In [20]:
df_hetero = pd.DataFrame({'a': [0, 1, 2], 'b': ['x', 'y', 'z']})
print(df_hetero)
In [21]:
print(df_hetero.dtypes)
In [22]:
a_hetero = df_hetero.values
print(a_hetero)
In [23]:
print(np.shares_memory(a_hetero, df_hetero))
In [24]:
df_hetero.iat[0, 0] = 100
print(df_hetero)
In [25]:
print(a_hetero)