What is the equivalent function for Panda dataframe..info() in vDataFrame - vertica-python

Pandas dataframe has an info function which shows information contained in the dataframe https://www.w3schools.com/python/pandas/ref_df_info.asp#:~:text=The%20info()%20method%20prints,method%20actually%20prints%20the%20info.
What is the equivalent function in vdataframe of VerticaPy? I tried describe and memory_usage but I don't see how many values each column has for example.

Related

R - how to use a function on a list of data frames

I have a little problem with my code. I hope you can help me :)
I used a function apply to create a list of 20 data frames (data about stock index returns, grouped by year and index - about three companies and the stock, for 5 years). And now I want to use function with two arguments (it calculates proportion of covariance of the returns for selected company and the stock to variance (for every year) - this is why I'm trying to group the data. How to do it... automatically, without manual typing code for every year and company?
I don't have any idea if I should use for loop or there is any other way...?
And the other thing is in which way can I delete uneccesary columns from list of data frames?
I'll be thankful for your help.
And sorry for my English :D
You may consider purrr::map_dfr(). The first argument will be your list of data frames, and the second the action to do with that data frame. The final result will be a single data frame uniting the result of all of the above. Your code will likely look something like this:
purrr::map_dfr(list_of_dataframes, function(x) {...})
Within the bracketes, instead of ... insert your logic. In that context, x will be the same as list_of_dataframes[[1]], and then list_of_dataframes[[2]], etc.
You may want to consult the documentation of the package purrr for further details.

R: combining data-frames row-wise when some variables are lists/dfs?

Is there a function in R that would let me combine/concatenate data-frames when some variables are either lists or data frames themselves? I've tried rbind(), rbindlist(), rbind.data.frame and bind_rows and they are all throwing out errors, e.g. duplicate 'row.names' are not allowed or Argument 4 can't be a list containing data frames.
After looking into it a bit, it seems that none of those functions support nested data-frames. Is there a function that would work for me? Or is there something (other than a for-loop that adds row by row) that I could do?
As a bit of a background, I'm making API-calls to a database and can get only 40 results at a time so I am looping through those via multiple calls, and I want to combine the results without any loss of information. I am using jsonlite:fromJSON to convert to a df: could I/should I combine the info in JSON format first and then convert to a df?

I am trying to create an individual document term matrix for each of the rows in my dataset. I have applied the following code to each

I am trying to establish a seperate document term matrix for each of the individual rows in a csv file. I have successfully read the csv file into R-Studio using the read.csv command. The first step to creating a document term matrix using the tm package, as far as I could figure out, would be to create an individual corpus for each of the rows of the file and to try and achieve this, I created the following code.
for(i in 1:no_row)
{
data$TextCorpus[i]<-Corpus(VectorSource(data$Text[i]))
#print(data$TextCorpus[i])
}
Where no_row equals the number of rows in the column (this was done using the command no_row<-nrow(data)) the data$TextCorpus column is a column I created to store the corpus's created by the loop and data$text refers to the column the data being used to create the individual corpus's.
I expected that this would produce a corpus for each of the individual rows however, when I apply the class() function to the data$Text_Corpus column, it says that the column is classed as a list and this is preventing me from applying tm_map functions to individual rows of a column. Furthermore, when I apply the as.Corpus function or any similar function to the column, this has no effect and still the data$TextCorpus column is classified as a list. Does anybody know how to fix this problem? It is greatly appreciated.
P.S. If corpus's isn't the plural of corpus, please feel free to correct me in your response.

readxlsx function limitations in openxlsx library

When I try to import an excel worksheet with readxlsx function it can be observed that in the preview there are more than 100 columns inserted into the data frame. But when I look inside the data frame, only the first 100 columns are visible. Thus, adding some columns and then using writexlsx is omitting those columns. Is there any way to avoid this situation?
Regards,
RafaƂ

Transform Dataframe to vector in R

I am attempting to pull a table from SQLServer and convert it to a vector in R.
I use sqlQuery() to return the table, which looks to be returned as a dataframe. I am curious, can I change all the values in this dataframe to be a vector?
I am currently using as.vector(nameofdataframe), which converts it to a list. I find that if I use as.vector(dataframe$column), it returns a vector, but I have many columns and I feel like there should be a much more simple way.
I was able to figure it out. If you take the data frame resulting from a sqlQuery() you need to use as.matrix first and then as.vector to the resulting matrix. Thank you all for your help.

Resources