-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
columns sometimes not added to empty dataframe #28871
Comments
The limit seems to be: test['2262'] = None #adds a new column
test['2261'] = None #doesnt add a column |
Various way to add the column described here: https://stackoverflow.com/a/50372722/1418484 either throw an error or fail to add the column: test = test.assign(**{'2010':None}) #no column is added
test = test.assign(**{'2010':test['3010']}) #error
test['2010'] = pd.Series(index=test.index) #error I was able to work around by just creating a new dataframe with the column test = pd.DataFrame(columns=list(test.columns)+['2010'],index=test.index) |
Thanks for the report. I'm guessing this is due to some underlying datetime inference as |
I dug into this a little bit - looks like the underlying problem is related to datetimes as @mroeschke suggested. The primary issue arises due to the fact that The
Since I'm not sure if this is truly a bug? However, I think it makes sense to add an additional check to the Welcome anyone's thoughts on this and I'd be happy to whip up a PR if necessary. |
Works now,
|
Code Sample, a copy-pastable example if possible
Problem description
The column '3010' is added to the dataframe as expected, but column 2010 does not get added.
Expected Output
Empty DataFrame
Columns: [3010, 2010]
Index: []
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.5.4.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 85 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 0.25.1
numpy : 1.17.2
pytz : 2019.3
dateutil : 2.8.0
pip : 9.0.1
setuptools : 36.4.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
openpyxl : None
odfpy : None
gcsfs : None
bottleneck : None
pandas_gbq : None
xarray : None
tables : None
scipy : None
pyarrow : None
xlsxwriter : None
matplotlib : None
sqlalchemy : None
pytables : None
xlwt : None
lxml.etree : None
s3fs : None
xlrd : None
numexpr : None
bs4 : None
fastparquet : None
The text was updated successfully, but these errors were encountered: