Sep-02-2020, 01:15 PM
I can do this:
I can also do this:
Is it accurate to say in more general terms that .loc and .iloc methods (and maybe others?) call for (row, column) whereas subsetting/slicing methods/syntax call for (column, row)?
If so, then is there a reason why it's not more consistent?
# creating a value with all null values in new data frame new["Null Column"]= NoneIn this example, the first argument in brackets calls for a column.
I can also do this:
>>>df = pd.DataFrame([[1, 2], [4, 5], [7, 8]], ... index=['cobra', 'viper', 'sidewinder'], ... columns=['max_speed', 'shield']) >>>df.loc['viper'] max_speed 4 shield 5 Name: viper, dtype: int64In this example, the first argument in brackets references a row.
Is it accurate to say in more general terms that .loc and .iloc methods (and maybe others?) call for (row, column) whereas subsetting/slicing methods/syntax call for (column, row)?
If so, then is there a reason why it's not more consistent?