tagged [dataframe]
Delete a column from a Pandas DataFrame
Delete a column from a Pandas DataFrame To delete a column in a DataFrame, I can successfully use: But why can't I use the following? Since it is possible to access the Series via `df.column_name`, I ...
How to create a dictionary of two pandas DataFrame columns
How to create a dictionary of two pandas DataFrame columns What is the most efficient way to organise the following pandas Dataframe: data = into a dictionary like `alphabet[1 : 'a', 2 : 'b', 3 : 'c',...
- Modified
- 4 Dec at 19:54
Combine two columns of text in pandas dataframe
Combine two columns of text in pandas dataframe I have a 20 x 4000 dataframe in Python using pandas. Two of these columns are named `Year` and `quarter`. I'd like to create a variable called `period` ...
Convert data.frame column format from character to factor
Convert data.frame column format from character to factor I would like to change the format (class) of some columns of my data.frame object (`mydf`) from to . I don't want to do this when I'm reading ...
Creating a zero-filled pandas data frame
Creating a zero-filled pandas data frame What is the best way to create a zero-filled pandas data frame of a given size? I have used: Is there a better way to do it?
How do I create test and train samples from one dataframe with pandas?
How do I create test and train samples from one dataframe with pandas? I have a fairly large dataset in the form of a dataframe and I was wondering how I would be able to split the dataframe into two ...
- Modified
- 10 Jun at 17:24
Get the name of a pandas DataFrame
Get the name of a pandas DataFrame How do I get the name of a DataFrame and print it as a string? Example: `boston` (var name assigned to a csv file)
- Modified
- 16 Dec at 10:29
Writing a pandas DataFrame to CSV file
Writing a pandas DataFrame to CSV file I have a dataframe in pandas which I would like to write to a CSV file. I am doing this using: And getting the following error: - -
Spark: subtract two DataFrames
Spark: subtract two DataFrames In Spark version one could use `subtract` with 2 `SchemRDD`s to end up with only the different content from the first one `onlyNewData` contains the rows in `todaySchemR...
- Modified
- 6 Oct at 09:52
Python Pandas: How to read only first n rows of CSV files in?
Python Pandas: How to read only first n rows of CSV files in? I have a very large data set and I can't afford to read the entire data set in. So, I'm thinking of reading only one chunk of it to train ...
Select first 4 rows of a data.frame in R
Select first 4 rows of a data.frame in R How can I select the first 4 rows of a `data.frame`:
How to replace text in a string column of a Pandas dataframe?
How to replace text in a string column of a Pandas dataframe? I have a column in my dataframe like this: and I want to replace the `,` comma with `-` dash. I'm currently using this method but nothing ...
How to loop through each row of dataFrame in pyspark
How to loop through each row of dataFrame in pyspark E.g The above statement prints theentire table on terminal. But I want to access each row in that table using `for` or `while` to perform further c...
- Modified
- 16 Dec at 17:36
Get current number of partitions of a DataFrame
Get current number of partitions of a DataFrame Is there any way to get the current number of partitions of a DataFrame? I checked the DataFrame javadoc (spark 1.6) and didn't found a method for that,...
- Modified
- 14 Oct at 16:28
Convert float64 column to int64 in Pandas
Convert float64 column to int64 in Pandas I tried to convert a column from data type `float64` to `int64` using: but got an error: > NameError: name 'int64' is not defined The column has number of peo...
Filtering Pandas DataFrames on dates
Filtering Pandas DataFrames on dates I have a Pandas DataFrame with a 'date' column. Now I need to filter out all rows in the DataFrame that have dates outside of the next two months. Essentially, I o...
List all column except for one in R
List all column except for one in R > [Drop Columns R Data frame](https://stackoverflow.com/questions/4605206/drop-columns-r-data-frame) Let's say I have a dataframe with column c1, c2, c3. I want t...
Pandas read_csv: low_memory and dtype options
Pandas read_csv: low_memory and dtype options ...gives an error: > .../site-packages/pandas/io/parsers.py:1130: DtypeWarning: Columns (4,5,7,16) have mixed types. Specify dtype option on import or set...
Pandas Replace NaN with blank/empty string
Pandas Replace NaN with blank/empty string I have a Pandas Dataframe as shown below: I want to remove the NaN values with an empty string so that it looks like so:
Renaming column names of a DataFrame in Spark Scala
Renaming column names of a DataFrame in Spark Scala I am trying to convert all the headers / column names of a `DataFrame` in Spark-Scala. as of now I come up with following code which only replaces a...
- Modified
- 17 Jun at 02:1
Check whether values in one data frame column exist in a second data frame
Check whether values in one data frame column exist in a second data frame I have two data frames (A and B), both with a column 'C'. I want to check if values in column 'C' in data frame A exists in d...
Find maximum value of a column and return the corresponding row values using Pandas
Find maximum value of a column and return the corresponding row values using Pandas ![Structure of data;](https://i.stack.imgur.com/a34it.png) Using Python Pandas I am trying to find the `Country` & `...
Move a column to first position in a data frame
Move a column to first position in a data frame I would like to have the last column of the data frame moved to the start (as first column). How can I do it in R? My data.frame has about a thousand co...