Fix Python – extracting days from a numpy.timedelta64 value

I am using pandas/python and I have two date time series s1 and s2, that have been generated using the ‘to_datetime’ function on a field of the df containing dates/times.
When I subtract s1 from s2

s3 = s2 – s1

I get a series, s3, of type

timedelta64[ns]

0 385 days, 04:10:36
1 57 days, 22:54:00
2 642 days, 21:15:23
3 615 days, 00….

Fix Python – How to plot two columns of a pandas data frame using points

I have a pandas dataframe and would like to plot values from one column versus the values from another column. Fortunately, there is plot method associated with the data-frames that seems to do what I need:
df.plot(x=’col_name_1′, y=’col_name_2′)

Unfortunately, it looks like among the plot styles (listed here after the kind parameter) there are n….

Fix Python – How to import data from mongodb to pandas?

I have a large amount of data in a collection in mongodb which I need to analyze. How do i import that data to pandas?
I am new to pandas and numpy.
EDIT:
The mongodb collection contains sensor values tagged with date and time. The sensor values are of float datatype.
Sample Data:
{
“_cls” : “SensorReport”,
“_id” : ObjectId(“515a963b78f6a035d9fa5….

Fix Python – What are the ‘levels’, ‘keys’, and names arguments for in Pandas’ concat function?

Questions

How do I use pd.concat?
What is the levels argument for?
What is the keys argument for?
Are there a bunch of examples to help explain how to use all the arguments?

Pandas’ concat function is the Swiss Army knife of the merging utilities. The variety of situations in which it is useful are numerous. The existing documentation leaves ou….

Fix Python – Check if string is in a pandas dataframe

I would like to see if a particular string exists in a particular column within my dataframe.
I’m getting the error

ValueError: The truth value of a Series is ambiguous. Use a.empty,
a.bool(), a.item(), a.any() or a.all().

import pandas as pd

BabyDataSet = [(‘Bob’, 968), (‘Jessica’, 155), (‘Mary’, 77), (‘John’, 578), (‘Mel’, 973)]

a = pd.DataF….

Fix Python – Splitting a pandas dataframe column by delimiter

i have a small sample data:
import pandas as pd

df = {‘ID’: [3009, 129, 119, 120, 121, 122, 130, 3014, 266, 849, 174, 844],
‘V’: [‘IGHV7-B*01’, ‘IGHV7-B*01’, ‘IGHV6-A*01’, ‘GHV6-A*01’, ‘IGHV6-A*01’,
‘IGHV6-A*01’, ‘IGHV4-L*03’, ‘IGHV4-L*03’, ‘IGHV5-A*01’, ‘IGHV5-A*04’,
‘IGHV6-A*02′,’IGHV6-A*02’],
‘Prob’: [1, 1, 0.8, 0.8056, 0.9….