In [1]:
import pandas as pd
In [2]:
df = pd.DataFrame({'col1': [0, 3, 2, 3], 'col2': [4, 0, 2, 1]},
index=['a', 'b', 'c', 'd'])
In [3]:
print(df)
In [4]:
print(df['col1'])
In [5]:
print(type(df['col1']))
In [6]:
print(df['col1'].max())
In [7]:
print(df['col1'].min())
In [8]:
print(df.max())
In [9]:
print(df.min())
In [10]:
print(df.max(axis=1))
In [11]:
print(df.min(axis=1))
In [12]:
print(type(df.max()))
In [13]:
print(df['col1'].idxmax())
In [14]:
print(df['col1'].idxmin())
In [15]:
print(df['col1'] == df['col1'].max())
In [16]:
print(df['col1'][df['col1'] == df['col1'].max()])
In [17]:
print(df['col1'][df['col1'] == df['col1'].max()].index)
In [18]:
print(df['col1'][df['col1'] == df['col1'].max()].index.values)
In [19]:
print(type(df['col1'][df['col1'] == df['col1'].max()].index.values))
In [20]:
print(list(df['col1'][df['col1'] == df['col1'].max()].index))
In [21]:
print(type(list(df['col1'][df['col1'] == df['col1'].max()].index)))
In [22]:
print(df['col1'][df['col1'] == df['col1'].min()].index.values)
In [23]:
print(df.loc['a'])
In [24]:
print(df.loc['a'].idxmax())
In [25]:
print(df.loc['a'].idxmin())
In [26]:
print(df.idxmax())
In [27]:
print(df.idxmin())
In [28]:
print(df.apply(lambda x: list(x[x == x.max()].index)))
In [29]:
print(df.apply(lambda x: list(x[x == x.min()].index)))
In [30]:
print(df.idxmax(axis=1))
In [31]:
print(df.idxmin(axis=1))
In [32]:
print(df.apply(lambda x: list(x[x == x.max()].index), axis=1))
In [33]:
print(df.apply(lambda x: list(x[x == x.min()].index), axis=1))
In [34]:
df_nan = df.copy()
df_nan.at['b'] = pd.np.nan
In [35]:
print(df_nan)
In [36]:
print(df_nan.idxmax())
In [37]:
print(df_nan.idxmin())
In [38]:
print(df_nan.idxmax(axis=1))
In [39]:
print(df_nan.idxmin(axis=1))
In [40]:
print(df_nan.idxmax(skipna=False))
In [41]:
print(df_nan.idxmin(skipna=False))
In [42]:
print(df_nan.idxmax(axis=1, skipna=False))
In [43]:
print(df_nan.idxmin(axis=1, skipna=False))
In [44]:
print(df_nan['col1'].idxmax())
In [45]:
print(df_nan['col1'].idxmin())
In [46]:
print(df_nan['col1'].idxmax(skipna=False))
In [47]:
print(df_nan['col1'].idxmin(skipna=False))