The red highlight part is pd.read_csv, we can get a dataframe type object here;
Then the blue highlight part is a list with lambda function (we can filter account ID when reading the CSV file).
This method seems very smart, but a bit confusing to me. Could anyone explain how this could work as a filter? Thank you very much.
CodePudding user response:
The [...]
part is called indexing, and basically there you're just creating a function (a "lambda" function) and indexing the dataframe with it. What you're going to get out of it is all the rows where acct_id
is OVIWFZA
.
It's identical to this:
df = pd.read_csv('/content/drive/client.csv', nrows=5)
df = df[df['acct_id'] == 'OVIWFZA']