Repository: pandas-dev/pandas
Pull request: add test to check type of df column after loc()
- [x] closes #23326
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).


Problem statement:
Data type of new assigned DataFrame column
```python

df = pd.DataFrame([list('abc')])
print(df)

df.loc[:, 'col1'] = int(5)
df['col2']        = int(5)
df                = df.assign(col3=int(5))

print(df.dtypes)
print(df)


  0  1  2
0  a  b  c
0        object
1        object
2        object
col1    float64
col2      int64
col3      int64
dtype: object
   0  1  2  col1  col2  col3
0  a  b  c   5.0     5     5
```
#### Problem description

The fact that `df.loc[:,'col1] = int(5)` yields a new column with dtype `float64` seems strange.

#### Expected Output

All three methods should yield a new column with dtype `int64`

#### Output of ``pd.show_versions()``

<details>
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.15.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-1023-aws
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: None.None

pandas: 0.23.4
pytest: 3.8.2
pip: 18.1
setuptools: 40.4.3
Cython: None
numpy: 1.15.0
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 5.8.0
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: 2.7.5 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
</details>

Hints from issue discussion:
Thanks for the report - investigation and PRs are certainly welcome!
i would like to give a try... 
This looks correct on master. Could use a test

```
In [22]: df = pd.DataFrame([list('abc')])
    ...: print(df)
    ...:
    ...: df.loc[:, 'col1'] = int(5)
    ...: df['col2']        = int(5)
    ...: df                = df.assign(col3=int(5))
    ...:
    ...: print(df.dtypes)
    ...: print(df)
   0  1  2
0  a  b  c
0       object
1       object
2       object
col1     int64
col2     int64
col3     int64
dtype: object
   0  1  2  col1  col2  col3
0  a  b  c     5     5     5
```

Commit message: double quotes

Patch to review:
diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py
index 1e5e65786a4aa..8760fdf5fb206 100644
--- a/pandas/tests/indexing/test_loc.py
+++ b/pandas/tests/indexing/test_loc.py
@@ -2869,6 +2869,13 @@ def test_loc_setitem_using_datetimelike_str_as_index(fill_val, exp_dtype):
     tm.assert_index_equal(df.index, expected_index, exact=True)
 
 
+def test_loc_set_int_dtype():
+    df = pd.DataFrame([list("abc")])
+    df.loc[:, "col1"] = int(5)
+
+    assert str(df.dtypes["col1"]) == "int64"
+
+
 class TestLocSeries:
     @pytest.mark.parametrize("val,expected", [(2**63 - 1, 3), (2**63, 4)])
     def test_loc_uint64(self, val, expected):


Code review comments:
diff_hunk: @@ -2869,6 +2869,13 @@ def test_loc_setitem_using_datetimelike_str_as_index(fill_val, exp_dtype):
     tm.assert_index_equal(df.index, expected_index, exact=True)
 
 
+def test_loc_set_int_dtype():
+    df = pd.DataFrame([list("abc")])
+    df.loc[:, "col1"] = int(5)
path: pandas/tests/indexing/test_loc.py
text: @user1:
```suggestion
    df.loc[:, "col1"] = 5
```

diff_hunk: @@ -2869,6 +2869,13 @@ def test_loc_setitem_using_datetimelike_str_as_index(fill_val, exp_dtype):
     tm.assert_index_equal(df.index, expected_index, exact=True)
 
 
+def test_loc_set_int_dtype():
+    df = pd.DataFrame([list("abc")])
+    df.loc[:, "col1"] = int(5)
+
+    assert str(df.dtypes["col1"]) == "int64"
path: pandas/tests/indexing/test_loc.py
text: @user1:
Generally we want to compare the complete `DataFrame` result which will check the dtype e.g.

```
df.loc[:, "col1"] = 5
expected = DataFrame(...)
tm.assert_frame_equal(df, expected)
```