Code Sample, a copy-pastable example if possible

import pandas as pd
import numpy as np

# Create a simple nested DataFrame
d = {"id": pd.Series([0,1,2]),
     "inner_df": pd.Series([pd.DataFrame(np.random.rand(4,4)) for _ in range(3)])}
outer_df = pd.DataFrame(d)

print("Old inner df in first row:")
print(outer_df.loc[0, "inner_df"])

# Now update the inner_df in the first row
new_inner_df = pd.DataFrame(np.random.rand(4, 4))


print("\n*** Results using loc ***")
outer_df.loc[0, "inner_df"] = new_inner_df

print("Expected new inner df in first row:")
print(new_inner_df)

print("Real new inner df in first row:")
print(outer_df.loc[0, "inner_df"])


print("\n*** Results using set_value ***")
outer_df.set_value(0, 'inner_df', new_inner_df)

print("Expected new inner df in first row:")
print(new_inner_df)

print("Real new inner df in first row:")
print(outer_df.loc[0, "inner_df"])


print("\n*** Results using concatenated indexing***")
outer_df["inner_df"][0] = new_inner_df

print("Expected new inner df in first row:")
print(new_inner_df)

print("Real new inner df in first row:")
print(outer_df.loc[0, "inner_df"])

Problem description

The most intuitive method using loc doesn't work if the new value is a dataframe. This leads users to use the third method using concatenated indexing, which should be avoided. The second method using set_value is also not mentioned in the tutorials/docs on indexing. Only by luck, I found a (semi-)related stack overflow question, which hinted to try set_value.

Thus I recommend: 1. Allow assigning a DataFrame to a single cell in a DataFrame or show an error hinting on set_value 2. Mention set_value here: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy

Expected Output

(included in script)

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.2.final.0 python-bits: 64 OS: Windows OS-release: 7 machine: AMD64 processor: Intel64 Family 6 Model 61 Stepping 4, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None pandas: 0.19.2 nose: 1.3.7 pip: 9.0.1 setuptools: 27.2.0 Cython: 0.25.2 numpy: 1.11.3 scipy: 0.18.1 statsmodels: 0.6.1 xarray: None IPython: 5.1.0 sphinx: 1.3.1 patsy: 0.4.1 dateutil: 2.6.0 pytz: 2016.10 blosc: None bottleneck: 1.2.0 tables: 3.2.2 numexpr: 2.6.1 matplotlib: 1.5.3 openpyxl: 2.4.1 xlrd: 1.0.0 xlwt: 1.2.0 xlsxwriter: 0.9.6 lxml: 3.7.2 bs4: 4.5.3 html5lib: None httplib2: None apiclient: None sqlalchemy: 1.1.4 pymysql: None psycopg2: None jinja2: 2.9.4 boto: 2.45.0 pandas_datareader: None

Comment From: jreback

Putting complex objects inside cells of a DataFrame is so non-idiomatic, non-performant and not supported, so closing as 'wont't fix'.