tagged [pandas]

Python Pandas: Convert Rows as Column headers

Python Pandas: Convert Rows as Column headers I have the following dataframe: I want it this way. ``` Yea

25 Jun at 13:12

Pandas plot doesn't show

Pandas plot doesn't show When using this in a script (not IPython), nothing happens, i.e. the plot window doesn't appear : Even when adding `time.sleep(5)`, there is still nothing. Why? Is there a way...

18 Dec at 01:23

how to merge two data frames based on particular column in pandas python?

how to merge two data frames based on particular column in pandas python? I have to merge two dataframes: df1 df2 I have to unify both dataframes to one dataframe. I need output like:

30 Jun at 13:7

How to lowercase a pandas dataframe string column if it has missing values?

How to lowercase a pandas dataframe string column if it has missing values? The following code does not work. How should I tweak it to get xLower = ['one','two',np.nan] ? Efficiency is important since...

14 May at 23:34

How to implement a Boolean search with multiple columns in pandas

How to implement a Boolean search with multiple columns in pandas I have a pandas df and would like to accomplish something along these lines (in SQL terms): Now this works, for one column/value pair:...

4 Oct at 00:0

How to calculate percentage with Pandas' DataFrame

How to calculate percentage with Pandas' DataFrame How to add another column to Pandas' DataFrame with percentage? The dict can change on size.

8 May at 10:59

move column in pandas dataframe

move column in pandas dataframe I have the following dataframe: How can I move columns b and x such that they are the last 2 columns in the dataframe? I would like to specify b and x by name, but not ...

10 Feb at 19:31

Pandas - Replace values based on index

Pandas - Replace values based on index If I create a dataframe like so: How would I change the entry in column A to be the number 16 from row 0 -15, for example? In other words, how do I replace cells...

14 Feb at 13:44

Difference between map, applymap and apply methods in Pandas

Difference between map, applymap and apply methods in Pandas Can you tell me when to use these vectorization methods with basic examples? I see that `map` is a `Series` method whereas the rest are `Da...

How to plot multiple dataframes in subplots

How to plot multiple dataframes in subplots I have a few Pandas DataFrames sharing the same value scale, but having different columns and indices. When invoking `df.plot()`, I get separate plot images...

cartesian product in pandas

cartesian product in pandas I have two pandas dataframes: What is the best practice to get their cartesian product (of course without writing it explicitly like me)?

Replacing Pandas or Numpy Nan with a None to use with MysqlDB

Replacing Pandas or Numpy Nan with a None to use with MysqlDB I am trying to write a Pandas dataframe (or can use a numpy array) to a mysql database using MysqlDB . MysqlDB doesn't seem understand 'na...

4 Jan at 12:20

Pandas DataFrame column to list

Pandas DataFrame column to list I am pulling a subset of data from a column based on conditions in another column being met. I can get the correct values back but it is in pandas.core.frame.DataFrame....

1 May at 11:31

add columns different length pandas

add columns different length pandas I have a problem with adding columns in pandas. I have DataFrame, dimensional is nxk. And in process I wiil need add columns with dimensional mx1, where m = [1,n], ...

25 Nov at 12:16

Logarithmic returns in pandas dataframe

Logarithmic returns in pandas dataframe Python pandas has a pct_change function which I use to calculate the returns for stock prices in a dataframe: I am using the following code to get logarithmic r...

8 Jul at 08:38

Python Pandas - Missing required dependencies ['numpy'] 1

Python Pandas - Missing required dependencies ['numpy'] 1 Since yesterday I've had this error when I try to import packages on anaconda : `ImportError: Missing required dependencies ['numpy']` I have ...

29 Feb at 12:23

How to draw vertical lines on a given plot

How to draw vertical lines on a given plot Given a plot of a signal in time representation, how can I draw lines marking the corresponding time index? Specifically, given a signal plot with a time ind...

11 Jul at 09:58

'DataFrame' object has no attribute 'sort'

'DataFrame' object has no attribute 'sort' I face some problem here, in my python package I have install `numpy`, but I still have this error: > Anyone can give me some idea.. This is my code : ``` fi...

22 Sep at 06:15

Binning a column with pandas

Binning a column with pandas I have a data frame column with numeric values: I want to see the column as [bin counts](https://en.wikipedia.org/wiki/Data_binning): How can I get the result as bins with...

25 Aug at 17:26

How to concatenate two dataframes without duplicates?

How to concatenate two dataframes without duplicates? I'd like to concatenate two dataframes `A`, `B` to a new one without duplicate rows (if rows in `B` already exist in `A`, don't add): Dataframe `A...

9 May at 15:19

TypeError: 'DataFrame' object is not callable

TypeError: 'DataFrame' object is not callable I've programmed these for calculating Variance I'm getting this error ``` Traceback (most recent call last): File "C:/Python34/project.py", line 11, in ...

5 Sep at 01:12

Make Pandas DataFrame apply() use all cores?

Make Pandas DataFrame apply() use all cores? As of August 2017, Pandas [DataFame.apply()](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.apply.html) is unfortunately still lim...

3 Jun at 21:55

Rename specific column(s) in pandas

Rename specific column(s) in pandas I've got a dataframe called `data`. How would I rename the only one column header? For example `gdp` to `log(gdp)`?

7 Apr at 09:42

Splitting timestamp column into separate date and time columns

Splitting timestamp column into separate date and time columns I have a pandas dataframe with over 1000 timestamps (below) that I would like to loop through: I'm having a hard time splitting this time...

4 Feb at 11:31

How to properly apply a lambda function into a pandas data frame column

How to properly apply a lambda function into a pandas data frame column I have a pandas data frame, `sample`, with one of the columns called `PR` to which am applying a lambda function as follows: ```...

25 May at 05:6