Skip to main content

All Questions

1 vote
2 answers
41 views

Python - Edit and Replace column values in a dataframe based on a column in another dataframe

I'm new to python and struck in a problem. df1 = pd.DataFrame({'col1': ['apple', 'banana', 'cherry', 'apple', 'cherry']}) df2 = pd.DataFrame({'col1': ['app Banana', 'Cherry', 'banana', 'apple', '...
Kush's user avatar
  • 13
0 votes
0 answers
24 views

Match two pandas data frames using one column in one data frame as default [duplicate]

I have say 2 data frames as below: df1 A B C 1 a X 1 b Y 1 c U 2 d T 3 k Z And 2nd data frame say as df2 A B C 1 a ...
Stan's user avatar
  • 884
1 vote
2 answers
47 views

Pandas Dataframe Not Displaying Column Elements

I merged two dataframes but the resulting dataframe is giving back an empty column. How can this be resolved? print(resampled_fd) Time power(dB) 0 2021-12-11 10:00:00 46.612 ...
Dub's user avatar
  • 13
0 votes
0 answers
45 views

How can i convert 31 colums (refering to the days of month) into a single datetime column?

I have this: Febuary_Sells (31 columns refering to the days of month) Store | Product | 1 | 2 | 3 | 4 | 5 | ... | 31 | Store 1 | Iphone | 0 | 3 | 1 | 3 | 2 | ... | 0 | Store 1 | 4k TV | 1 ...
fgu1lherme's user avatar
0 votes
1 answer
26 views

How to sort multiple columns under new columns based on row values from another column within the same dataframe pandas?

This is my dataset: Name India Japan USA France Italy Continent Foo 1 1 0 0 0 Asia Baz 0 0 1 0 0 N.America Bob 0 0 0 1 1 Europe How I want the result to look like: | | Asia | N. America | ...
Mimikyu o_0's user avatar
0 votes
2 answers
294 views

How to concatenate two columns so that one comes below the other in pandas dataframe?

Col-1 Col-2 0 Erin Tanya 1 Cathy Tom 2 Ross Wes This is my dataset I need the result to look like this: New_column 0 Erin 1 Cathy 2 Ross 3 Tanya 4 Tom 5 Wes I tried using .map, ...
Mimikyu o_0's user avatar
0 votes
1 answer
488 views

Merge two columns from multiple panda series dataframes based on string matching from two columns with different values

I need to merge two columns from a pandas series dataframe together on the last 4 digits of the first column pack_number. I currently have 2 dataframes with a different number of columns. So far, I ...
ashleybee's user avatar
0 votes
3 answers
62 views

Is there a way to make from four columns one column based on several conditions in python?

The problem is that I can not make one column out of four based on my conditions. Programming language - python. #for demonstration import pandas as pd example = { "color ID": [1, 2,3, 4, 5]...
Shu's user avatar
  • 67
1 vote
2 answers
44 views

Merging two columns in a single pandas data frame

I have the following data frame: df = pd.DataFrame({'id': [0.1, 0.2, 0.3, 0.4],'A': [1,2, np.NaN, np.NaN], 'A1': [np.NaN, np.NaN, 3,4]}) I'm looking to merge A1 into A (drop A1) that should result ...
codemechanics's user avatar
1 vote
2 answers
509 views

join two pandas dataframes by two columns without order

I have two dataframes which look like this: net1 Gene_A Gene_B abs_dif log2FC omic 0 RBL2 ATOH7 0.277574 0.634319 trans 1 RBL2 USF2 0.276369 0.567421 trans 2 RBL2 RASA3 0.166101 0.474418 trans net2 ...
Fernando Delgado Chaves's user avatar
0 votes
1 answer
64 views

Merging two files with a specific character through Pandas

Input: file1 0 1 2 ch1 SLC d4p ch1 WEK d20i ch2 XLW k13q ch2 PCX w2p ch3 KCE p102x ch3 KXS m7t Input: file2 0 1 KKC lsdkjlcjskndv SLC slkdmcokwem PCX ...
LoganLee's user avatar
  • 147
0 votes
2 answers
167 views

Merge rows with same id, different vallues in 1 column to multiple columns

what i have length can be of different values/ so somethimes 1 id has 4 rows with different values in column val, the other columns have all the same values df1 = pd.DataFrame({'id':[1,1,1,2,2,2,3,3,3]...
y2020's user avatar
  • 1
0 votes
1 answer
68 views

Merging two DF's on shortest date record and delete non-matching date rows

i have two df's that i need to merge into one new df based on the day, month and year of the df with the shortest record of day, month and year. In other words, if the "day", "month&...
user2100039's user avatar
  • 1,366
0 votes
1 answer
59 views

How to merge several csv file during a loop by joining columns on columns

here 's my problem. I have 100 files, they all have two columns: 'time_slope' and 'slope'. I would like to create a single file with everything in it. Here is an example: -----file 1---- 2001.1 ...
Pierre's user avatar
  • 23
0 votes
2 answers
63 views

Merge specific column in multiple dataframe with different length

df1 Color date 0 A 2011 1 B 201411 2 C 20151231 3 A 2019 df2 Color date 0 A 2013 1 B 20151111 2 C 201101 df3 Color date 0 ...
ybin's user avatar
  • 575

15 30 50 per page