Why is the behavior when assigning to values inconsistent?

时间:2017-08-30 20:12:42

标签: python pandas numpy dataframe

Consider the two DataFrames . . . files: [ { pattern: 'node_modules/abc/abc.min.css', included:true, watched: false } ], and @Before public void openBrowser() { String url = ("https://loadfocus.com/blog/2016/06/13/how-to-select-adropdown-in-selenium-webdriver-using-java"); driver = utility.Utils.openBrowser(driver, url); } @Test public void open() { Select dropdown = new Select(driver.findElement(By.id("mySelect"))); dropdown.selectByIndex(2); } :

If Not ImportDialog.InitialDirectory.Contains("Direct Access\Shell\Customer Invoices") Then
        ImportDialog.InitialDirectory = "....\Direct Access\Shell\Customer Invoices\"
End If

I want to overwrite the first column of d1. It starts off as:

d2

I attempt to overwrite the values of d1 = pd.DataFrame(np.arange(2).reshape(-1, 2), columns=['A', 'B']) d2 = pd.DataFrame(dict(A=[0], B=list('a'))) with:

d1

However when I do the same thing with d1 A B 0 0 1 , I get different results.

'A'

Then:

d1.values[:, 0] = 2
d1

   A  B
0  2  1

Nothing has changed, except when I do:

d2

Why is this behavior inconsistent?

1 个答案:

答案 0 :(得分:6)

Because of the mixed ObservableCollection<Item>s in SELECT DISTINCT (package_id) FROM EXT WHERE Item_param_attr_name = 'Usage category group' AND Item_param_attr_value = 'H' AND package_id IN (SELECT DISTINCT (package_id) FROM EXT WHERE Item_param_attr_name = 'Charge code' AND Item_param_attr_value = 'WDATRM' AND Priority > 299 AND package_id IN (SELECT DISTINCT (package_id) FROM EXT WHERE Item_param_attr_name = 'Charge code' AND Item_param_attr_value = 'WDA4RM' AND package_id IN (SELECT DISTINCT (package_id) FROM EXT WHERE ITEM_PARAM_ATTR_NAME = 'Rate table rate' AND ITEM_PARAM_ATTR_VALUE = '0.00000953'))); you'll get an devServer: { historyApiFallback: true, noInfo: true, setup(app){ app.get('/logincallback', function(req, res) { res.sendFile(path.join(__dirname + '/callback.html')); }); } }, -array (copy) when you access the whole dtype.

d2

This happens for any non-identical datatypes, e.g. also for object vs. .values:

>>> d2.values
array([[0, 'a']], dtype=object)

The changes only propagate back if the dtype is exactly the same for all columns:

int32

Just to give an (approximate) way to find out if it's a view or a copy of the actual column you could use np.shares_memory:

int64