I have the following table: Note: Both NSRCODE and PBL_AWI are index’s Note: the % Of area column would be filled out just have not done so yet. NSRCODE PBL_AWI Area % Of Area …

# Tag: pandas

## How to merge two dataframe in pandas to replace nan

I want to do this in pandas: I have 2 dataframes, A and B, I want to replace only NaN of A with B values. A 2014-04-17 12:59:00 146.06250 146.0625 …

## How to read a file with a semi colon separator in pandas

I a importing a .csv file in python with pandas. Here is the file format from the .csv : a1;b1;c1;d1;e1;… a2;b2;c2;d2;e2;… ….. here is how get it : from pandas import * csv_path = “C:…….

## Pandas: Group by calendar-week, then plot grouped barplots for the real datetime

EDIT I found a quite nice solution and posted it below as an answer. The result will look like this: Some example data you can generate for this problem: codes = list(‘ABCDEFGH’); dates = pd….

## How to get output of pandas .plot(kind=’kde’)?

When I plot density distribution of my pandas Series I use Is it possible to get output values of this plot? If yes how to do this? I need the plotted values. Answer There are no output value from .plot(kind=’kde’), it returns a axes object. The raw values can be accessed by _x and _y method of the matplotlib.lines.Line2D object

## 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 random samples (80% and 20%) for training and testing. Thanks! Answer I would just use numpy’s randn: And just to see this has worked:

## pandas apply function that returns multiple values to rows in pandas dataframe

I have a dataframe with a timeindex and 3 columns containing the coordinates of a 3D vector: x y z ts 2014-05-15 10:38 0.120117 0.987305 …

## Check if a value exists in pandas dataframe index

I am sure there is an obvious way to do this but cant think of anything slick right now. Basically instead of raising exception I would like to get True or False to see if a value exists in pandas df index. What I have working now is the following Answer This should do the trick

## How to do/workaround a conditional join in python Pandas?

I am trying to calculate time-based aggregations in Pandas based on date values stored in a separate tables. The top of the first table table_a looks like this: Here is the code to create the table: The second table, table_b, looks like this: and the code to create it is: I want to be able to get the sum of

## How to write DataFrame to postgres table?

There is DataFrame.to_sql method, but it works only for mysql, sqlite and oracle databases. I cant pass to this method postgres connection or sqlalchemy engine.