{"action":"created","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/21495","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21495/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21495/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21495/events","html_url":"https://github.com/pandas-dev/pandas/issues/21495","id":332718440,"node_id":"MDU6SXNzdWUzMzI3MTg0NDA=","number":21495,"title":"Worked in 0.22, ceased to work in 0.23: assigning varied values to a DataFrame column slice without the need to put [0] at the end ","user":{"login":"Pawel-Kranzberg","id":7954786,"node_id":"MDQ6VXNlcjc5NTQ3ODY=","avatar_url":"https://avatars0.githubusercontent.com/u/7954786?v=4","gravatar_id":"","url":"https://api.github.com/users/Pawel-Kranzberg","html_url":"https://github.com/Pawel-Kranzberg","followers_url":"https://api.github.com/users/Pawel-Kranzberg/followers","following_url":"https://api.github.com/users/Pawel-Kranzberg/following{/other_user}","gists_url":"https://api.github.com/users/Pawel-Kranzberg/gists{/gist_id}","starred_url":"https://api.github.com/users/Pawel-Kranzberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pawel-Kranzberg/subscriptions","organizations_url":"https://api.github.com/users/Pawel-Kranzberg/orgs","repos_url":"https://api.github.com/users/Pawel-Kranzberg/repos","events_url":"https://api.github.com/users/Pawel-Kranzberg/events{/privacy}","received_events_url":"https://api.github.com/users/Pawel-Kranzberg/received_events","type":"User","site_admin":false},"labels":[{"id":307649777,"node_id":"MDU6TGFiZWwzMDc2NDk3Nzc=","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Needs%20Info","name":"Needs Info","color":"207de5","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-15T10:09:00Z","updated_at":"2018-06-27T08:40:41Z","closed_at":"2018-06-27T08:40:41Z","author_association":"NONE","body":"#### Code Sample, a copy-pastable example if possible\r\nThe following sample worked in 0.22 but no longer works in 0.23.\r\n```python\r\n# Sample 1\r\ndf0.flight_number[pd.isna(df0.airline_icao)] = df0.flight_number[pd.isna(df0.airline_icao)].str.extract('^\\(?([A-Z]{3})')\r\n```\r\nRewriting it as follows does not help.\r\n```python\r\n# Sample 2\r\ndf0.loc[pd.isna(df0.airline_icao), 'airline_icao'] = df0.flight_number[pd.isna(df0.airline_icao)].str.extract('^\\(?([A-Z]{3})')\r\n# Sample 3\r\ndf0.loc[pd.isna(df0.airline_icao), 'airline_icao'] = df0.loc[pd.isna(df0.airline_icao), 'flight_number'].str.extract('^\\(?([A-Z]{3})')\r\n```\r\nThis version works:\r\n```python\r\ndf0.loc[pd.isna(df0.airline_icao), 'airline_icao'] = df0.loc[pd.isna(df0.airline_icao), 'flight_number'].str.extract('^\\(?([A-Z]{3})')[0]\r\n```\r\n\r\n#### Problem description\r\nThe problem for me is that values from the slices on the right right do not make it to the left slices, unless [0] is at the end. However, all the slicing (and extracting on the right, as well as other data transformations) in samples 1, 2, 3 still works fine. I suppose the problem is caused by the fact that there are Series on the left, and single-column DataFrames on the right.\r\n\r\nAt the same time, the following code works both in 0.22 and 0.23, maybe because there are Series both on the left and right:\r\n\r\n```python\r\nflights['distance_km'] = flights.apply(lambda x: dist((x['latitude'], x['longitude']), (x['latitude_d'], x['longitude_d'])), axis = 1)\r\nS031_flight_distance_list = {1500: 'below1500', 3500: '1500to3500', np.inf: 'above3500'}\r\n\r\nflights.distance[~flights.distance.map(lambda x: x in S031_flight_distance_list.values())] = pd.cut(flights.distance_km[~flights.distance.map(lambda x: x in S031_flight_distance_list.values())], bins = [0] + list(S031_flight_distance_list.keys()), labels = S031_flight_distance_list.values())\r\n\r\n```\r\n#### Expected Output\r\n``` python\r\ndf0.loc[pd.isna(df0.airline_icao), 'airline_icao']\r\nOut[105]: \r\n61        NaN\r\n62        NaN\r\n67        NaN\r\n68        NaN\r\n69        NaN\r\n75        NaN\r\n150       NaN\r\n792       NaN\r\n794       NaN\r\n1034      NaN\r\n1036      NaN\r\n1037      NaN\r\n1141      NaN\r\n1142      NaN\r\n1143      NaN\r\n1144      NaN\r\n1145      NaN\r\n1234      NaN\r\n\r\ndf0.loc[pd.isna(df0.airline_icao), 'flight_number'].str.extract('^\\(?([A-Z]{3})')\r\nOut[106]: \r\n          0\r\n61      NaN\r\n62      NaN\r\n67      NaN\r\n68      NaN\r\n69      NaN\r\n75      ARZ\r\n150     NaN\r\n792     NaN\r\n794     NaN\r\n1034    NaN\r\n1036    NaN\r\n1037    ENT\r\n1141    NaN\r\n1142    NaN\r\n1143    NaN\r\n1144    NaN\r\n1145    NaN\r\n1234    ARZ\r\n\r\n# The following code should result in putting e.g. 'ARZ' in row 75 of df0.flight_number:\r\ndf0.loc[pd.isna(df0.airline_icao), 'airline_icao'] = df0.loc[pd.isna(df0.airline_icao), 'flight_number'].str.extract('^\\(?([A-Z]{3})')\r\n\r\n```\r\n\r\n#### Output of ``pd.show_versions()``\r\n\r\n<details>\r\n\r\n[paste the output of ``pd.show_versions()`` here below this line]\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: None\r\npython: 3.6.4.final.0\r\npython-bits: 64\r\nOS: Windows\r\nOS-release: 10\r\nmachine: AMD64\r\nprocessor: Intel64 Family 6 Model 158 Stepping 9, GenuineIntel\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: en\r\nLOCALE: None.None\r\n\r\npandas: 0.23.0\r\npytest: 3.3.2\r\npip: 10.0.1\r\nsetuptools: 38.4.0\r\nCython: 0.27.3\r\nnumpy: 1.14.0\r\nscipy: 1.0.0\r\npyarrow: None\r\nxarray: None\r\nIPython: 6.2.1\r\nsphinx: 1.6.6\r\npatsy: 0.5.0\r\ndateutil: 2.6.1\r\npytz: 2017.3\r\nblosc: None\r\nbottleneck: 1.2.1\r\ntables: 3.4.2\r\nnumexpr: 2.6.4\r\nfeather: None\r\nmatplotlib: 2.1.2\r\nopenpyxl: 2.4.10\r\nxlrd: 1.1.0\r\nxlwt: 1.3.0\r\nxlsxwriter: 1.0.2\r\nlxml: 4.2.1\r\nbs4: 4.6.0\r\nhtml5lib: 1.0.1\r\nsqlalchemy: 1.2.1\r\npymysql: None\r\npsycopg2: None\r\njinja2: 2.10\r\ns3fs: None\r\nfastparquet: None\r\npandas_gbq: 0.4.1\r\npandas_datareader: None\r\n\r\n</details>\r\n"},"comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments/400590896","html_url":"https://github.com/pandas-dev/pandas/issues/21495#issuecomment-400590896","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21495","id":400590896,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDU5MDg5Ng==","user":{"login":"Pawel-Kranzberg","id":7954786,"node_id":"MDQ6VXNlcjc5NTQ3ODY=","avatar_url":"https://avatars0.githubusercontent.com/u/7954786?v=4","gravatar_id":"","url":"https://api.github.com/users/Pawel-Kranzberg","html_url":"https://github.com/Pawel-Kranzberg","followers_url":"https://api.github.com/users/Pawel-Kranzberg/followers","following_url":"https://api.github.com/users/Pawel-Kranzberg/following{/other_user}","gists_url":"https://api.github.com/users/Pawel-Kranzberg/gists{/gist_id}","starred_url":"https://api.github.com/users/Pawel-Kranzberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pawel-Kranzberg/subscriptions","organizations_url":"https://api.github.com/users/Pawel-Kranzberg/orgs","repos_url":"https://api.github.com/users/Pawel-Kranzberg/repos","events_url":"https://api.github.com/users/Pawel-Kranzberg/events{/privacy}","received_events_url":"https://api.github.com/users/Pawel-Kranzberg/received_events","type":"User","site_admin":false},"created_at":"2018-06-27T08:40:41Z","updated_at":"2018-06-27T08:40:41Z","author_association":"NONE","body":"I'm to busy now to work on this. I'll reopen it when I have a better example."}}
{"actor":{"display_login":"Pawel-Kranzberg"}}