Closed
Description
#Under pandas==0.23.0
import pandas
df1 = pd.DataFrame([[1]], columns = [[1]], index = [ 1, 2 ])
print(df1)
df2 = pd.DataFrame([[1]], columns = [[1]], index = [ [ 1, 2 ] ])
print(df2)
Output:
1
1 1
2 1
ValueError: Shape of passed values is (1, 1), indices imply (1, 2)
#Under pandas==0.22.0, this issue did not arise.
import pandas
df1 = pd.DataFrame([[1]], columns = [[1]], index = [ 1, 2 ])
print(df1)
df2 = pd.DataFrame([[1]], columns = [[1]], index = [ [ 1, 2 ] ])
print(df2)
Output:
1
1 1
2 1
1
1 1
2 1
It seems that if the index is just a list then broadcasting the values occurs. If it a list of lists, the index still maintains the same shape but broadcasting is not done in this case.
Output of pd.show_versions()
pandas: 0.23.0
pytest: None
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.11.3
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: 1.8.2
patsy: 0.5.1
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: 3.2.2
numexpr: 2.6.8
feather: None
matplotlib: 3.0.1
openpyxl: None
xlrd: 1.2.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: 1.2.7
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: 0.7.0