Category "pandas"

How to solve (NaN error) when given column specific name

I have many text files include data as follow: 350.0 2.1021 0.0000 1.4769 0.0000 357.0 2.0970 0.0000 1.4758 0.0000 364.0 2.0920 0.0000

How to select multiple columns by name that are not adjacent and combining several slicing methods?

Is there a way to select multiple columns that are not adjacent and combining several methods? test dataframe: test = pd.DataFrame(np.random.rand(3, 9),

Pandas- DataError: No numeric types to aggregate

I have a DataFrame with 5 columns, where the column i need to aggregate is of a string, and has NaN values. I tried replacing the nan values with 0 and then con

Fastest way to iterate subsets of rows in pandas dataframe based on condition

I have a dataframe with a column of IDs and a column of values - each ID is associated with two or more rows. When any subset of values within a given ID meets

Python Pandas read_sql rounds and converts numbers

I'm executing a query on IBM DB2 server with ibm_db_dbi. Here is my query: connection = ibm_db_dbi.connect(hostSettings, '', '') ret = pd.read_sql(query, connec

Rearrange pandas Dataframes

I decide to simplify my post and replace images with code which has the same structure (and problem) inside and everyone could 'copy-paste' this example to try

How to slice multiple sections of dataframe by column name?

How do I get the first column, then add another slice? For example: import pandas as pd df = pd.DataFrame(pd.np.random.rand(6,6), columns = list('abcdef'))

How to read csv from ftp using pandas? [duplicate]

I connected to a sftp and got a list of files successfully: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy

If value is greater than the previous replace with previous in Pandas

I am working on a data processing script that does some basic calcs from data files and sorts the data. The last piece to the puzzle is identifying if the next

How to replace column values with dictionary keys

I have a df, A B one six two seven three level five one and a dictionary my_dict={1:"one,two",2:"three,four"} I want to replace df.A with my_di

df.to_csv function prints out the content instead of writing data to a file

df.to_csv(output_file) is supposed to write the content of a DataFrame to a file. While the function is working for 99.9% of the file in my directory, there is

TENSORFLOW: UNSUPPORTABLE CALLABLE

I am trying to build the following model but am getting this error when I am finally training the model and trying to get it's accuracy. It gets stuck when I am

Converting datetime only to time in pandas

I would like to ask a question regarding converting datetime only to time. I have values 'Date Created" that include Dates and Times in one column and I would l

How to indicate leading zero differences row wise?

I have this as the ID numbers: "00456, 0000456, 567, 00567" in a dataframe called "test". I created a dataframe where it has the IDs with leading zeros in a col

Python Pandas - Find difference between two data frames

I have two data frames df1 and df2, where df2 is a subset of df1. How do I get a new data frame (df3) which is the difference between the two data frames? In o

How to open a .tsv file in Jupyter? Jupyter.Notebook tried suggestions, but it doesn't work

How can I open a .tsv file in Jupyter. The data is stored under C:/User/anna/. This is my code: import pandas as pd df=pd.read_csv('C:/User/anna/train') Bu

Pandas - Duplicate Rows and Slice String

I'm trying to create duplicate rows during a dataframe on conditions. For example, I have this Dataframe. students = [ ("a", "Ursula"), ("b", "Hayfa, Ma

Python Dataframes - Breaking out single rows with duplicate columns into multiple rows and fewer columns

I have a data frame like this: A B C Date1 Time1 Value1 Date2 Time2 Value2 abc def ghi 01-01-2000 15:00:00 100 01-01-2000 19:00:00 110 There are duplicate col

Pandas - Add a new column extracting value from arrays based on other column value

I am currently stuck trying to extract a value from a list/array depending on values of a dataframe. Imagine i have this array. This array i can manually create

Pandas - Add a new column extracting value from arrays based on other column value

I am currently stuck trying to extract a value from a list/array depending on values of a dataframe. Imagine i have this array. This array i can manually create