Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accessing the rows in vaex dataframe. #494

Closed
RAJAT8878 opened this issue Dec 10, 2019 · 9 comments
Closed

accessing the rows in vaex dataframe. #494

RAJAT8878 opened this issue Dec 10, 2019 · 9 comments

Comments

@RAJAT8878
Copy link

In pandas, we have a facility for accessing the rows from loc or iloc method. Is there any way by which we can access the specific rows for vaex dataframe.

@maartenbreddels
Copy link
Member

Vaex has no index (yet), so by default all access is row based.
This should work.

import vaex
df = vaex.example()
df['x'].values[0]

Note that if x is virtual column, every time you access .values it will have to be computed (thus slow). So you may want to assign it to a local variable. If x is too large, you may want to get a chunk:

import vaex
df = vaex.example()
chunk = df['x'][:10000].values
chunk[0]

What is the reason to access an individual value, may I ask?

@RAJAT8878
Copy link
Author

Hi @maartenbreddels It's not about accessing an individual value or not any columns value. Let's suppose i wanted to filter by index where index is in timestamp format. since loc and iloc is very common for selecting the subset of data based on the condition.

@maartenbreddels
Copy link
Member

Could you be more specific on what you want, like give a pandas example? Thanks!

@JovanVeljanoski
Copy link
Member

Will close this as stale - please reopen if needed. Thanks!

@calebjacksonhoward
Copy link

How might I do this sort of selective modification of a vaex dataframe?

import pandas as pd
import numpy as np

id      = [2, 3, 7, 9, 10, 11]
truth   = [False, False, False, False, False, False]
df      = pd.DataFrame({'id': id, 'truth': truth})

filter      = [3, 10]
selection   = [i in filter for i in id]

df.loc[selection, 'truth'] = True

print(df)

@vijaybabupalli
Copy link

In pandas, we have a facility for accessing the rows from loc or iloc method. Is there any way by which we can access the specific rows for vaex dataframe.

@FrancescoSaverioZuppichini

any update?

@NickCrews
Copy link
Contributor

FYI the issue is closed, so maintainers aren't going to look at it. Open a new issue if you need it, and please be specific with what you need. The solution that was posted works great for accessing specific rows and columns.

@calebjacksonhoward, for selective modifcation, you need to use where(): https://vaex.io/docs/api.html#vaex.expression.Expression.where

@chaoshunihao
Copy link

import vaex
df=vaex.example()
df[1:5]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants