id
stringlengths
13
16
content
stringlengths
1.24k
122k
ds1000_data_1
Problem: I have the following DataFrame: Col1 Col2 Col3 Type 0 1 2 3 1 1 4 5 6 1 2 7 8 9 2 3 10 11 12 2 4 13 14 15 3 5 16 17 18 3 The DataFrame is read from a CSV file. All rows which have Type 1 are on top, followed by t...
ds1000_data_2
Problem: I have the following DataFrame: Col1 Col2 Col3 Type 0 1 2 3 1 1 4 5 6 1 2 7 8 9 2 3 10 11 12 2 4 13 14 15 3 5 16 17 18 3 The DataFrame is read from a CSV file. All rows which have Type 1 are on top, followed by t...
ds1000_data_3
Problem: I have following pandas dataframe : import pandas as pd from pandas import Series, DataFrame data = DataFrame({'Qu1': ['apple', 'potato', 'cheese', 'banana', 'cheese', 'banana', 'cheese', 'potato', 'egg'], 'Qu2': ['sausage', 'banana', 'apple', 'apple', 'apple', 'sausage', 'banana', 'banana', '...
ds1000_data_4
Problem: I have following pandas dataframe : import pandas as pd from pandas import Series, DataFrame data = DataFrame({'Qu1': ['apple', 'potato', 'cheese', 'banana', 'cheese', 'banana', 'cheese', 'potato', 'egg'], 'Qu2': ['sausage', 'banana', 'apple', 'apple', 'apple', 'sausage', 'banana', 'banana', 'b...
ds1000_data_5
Problem: I have following pandas dataframe : import pandas as pd from pandas import Series, DataFrame data = DataFrame({'Qu1': ['apple', 'potato', 'cheese', 'banana', 'cheese', 'banana', 'cheese', 'potato', 'egg'], 'Qu2': ['sausage', 'banana', 'apple', 'apple', 'apple', 'sausage', 'banana', 'banana', '...
ds1000_data_6
Problem: I have following pandas dataframe : import pandas as pd from pandas import Series, DataFrame data = DataFrame({'Qu1': ['apple', 'potato', 'cheese', 'banana', 'cheese', 'banana', 'cheese', 'potato', 'egg'], 'Qu2': ['sausage', 'banana', 'apple', 'apple', 'apple', 'sausage', 'banana', 'banana', 'b...
ds1000_data_7
Problem: I have following pandas dataframe : import pandas as pd from pandas import Series, DataFrame data = DataFrame({'Qu1': ['apple', 'potato', 'cheese', 'banana', 'cheese', 'banana', 'cheese', 'potato', 'egg'], 'Qu2': ['sausage', 'banana', 'apple', 'apple', 'apple', 'sausage', 'banana', 'banana', 'b...
ds1000_data_8
Problem: I have a dataset : id url keep_if_dup 1 A.com Yes 2 A.com Yes 3 B.com No 4 B.com No 5 C.com No I want to remove duplicates, i.e. keep first occurence of "url" field, BUT keep duplicates if the field "keep_if_dup" is YES. Expected output : id url keep_if_dup 1 ...
ds1000_data_9
Problem: I have a dataset : id url drop_if_dup 1 A.com Yes 2 A.com Yes 3 B.com No 4 B.com No 5 C.com No I want to remove duplicates, i.e. keep first occurence of "url" field, BUT keep duplicates if the field "drop_if_dup" is No. Expected output : id url drop_if_dup 1 A....
ds1000_data_10
Problem: I have a dataset : id url keep_if_dup 1 A.com Yes 2 A.com Yes 3 B.com No 4 B.com No 5 C.com No I want to remove duplicates, i.e. keep last occurence of "url" field, BUT keep duplicates if the field "keep_if_dup" is YES. Expected output : id url keep_if_dup 1 A....
ds1000_data_11
Problem: I'm Looking for a generic way of turning a DataFrame to a nested dictionary This is a sample data frame name v1 v2 v3 0 A A1 A11 1 1 A A2 A12 2 2 B B1 B12 3 3 C C1 C11 4 4 B B2 B21 5 5 A A2 A21 6 The number of columns may differ and so does the ...
ds1000_data_12
Problem: I have been struggling with removing the time zone info from a column in a pandas dataframe. I have checked the following question, but it does not work for me: Can I export pandas DataFrame to Excel stripping tzinfo? I used tz_localize to assign a timezone to a datetime object, because I need to convert t...
ds1000_data_13
Problem: I have been struggling with removing the time zone info from a column in a pandas dataframe. I have checked the following question, but it does not work for me: Can I export pandas DataFrame to Excel stripping tzinfo? I used tz_localize to assign a timezone to a datetime object, because I need to convert t...
ds1000_data_14
Problem: I have been struggling with removing the time zone info from a column in a pandas dataframe. I have checked the following question, but it does not work for me: Can I export pandas DataFrame to Excel stripping tzinfo? I used tz_localize to assign a timezone to a datetime object, because I need to convert t...
ds1000_data_15
Problem: I have been struggling with removing the time zone info from a column in a pandas dataframe. I have checked the following question, but it does not work for me: Can I export pandas DataFrame to Excel stripping tzinfo? I used tz_localize to assign a timezone to a datetime object, because I need to convert t...
ds1000_data_16
Problem: I have a data set like below: name status number message matt active 12345 [job: , money: none, wife: none] james active 23456 [group: band, wife: yes, money: 10000] adam inactive 34567 [job: none, money: none, wife: , kids: one, group: jail] How can I extract the key value ...
ds1000_data_17
Problem: I have a dataframe that looks like this: product score 0 1179160 0.424654 1 1066490 0.424509 2 1148126 0.422207 3 1069104 0.420455 4 1069105 0.414603 .. ... ... 491 1160330 0.168784 492 1069098 0.168749 493 1077784 0.168738 494 1193369 0.168703 495 1179741 0.1...
ds1000_data_18
Problem: I have a dataframe that looks like this: product score 0 1179160 0.424654 1 1066490 0.424509 2 1148126 0.422207 3 1069104 0.420455 4 1069105 0.414603 .. ... ... 491 1160330 0.168784 492 1069098 0.168749 493 1077784 0.168738 494 1193369 0.168703 495 1179741 0.1...
ds1000_data_19
Problem: I have a dataframe that looks like this: product score 0 1179160 0.424654 1 1066490 0.424509 2 1148126 0.422207 3 1069104 0.420455 4 1069105 0.414603 .. ... ... 491 1160330 0.168784 492 1069098 0.168749 493 1077784 0.168738 494 1193369 0.168703 495 1179741 0.1...
ds1000_data_20
Problem: I have a dataframe that looks like this: product score 0 1179160 0.424654 1 1066490 0.424509 2 1148126 0.422207 3 1069104 0.420455 4 1069105 0.414603 .. ... ... 491 1160330 0.168784 492 1069098 0.168749 493 1077784 0.168738 494 1193369 0.168703 495 1179741 0.1...
ds1000_data_21
Problem: Given a pandas DataFrame, how does one convert several binary columns (where 1 denotes the value exists, 0 denotes it doesn't) into a single categorical column? Another way to think of this is how to perform the "reverse pd.get_dummies()"? Here is an example of converting a categorical column into several bi...
ds1000_data_22
Problem: Given a pandas DataFrame, how does one convert several binary columns (where 0 denotes the value exists, 1 denotes it doesn't) into a single categorical column? Another way to think of this is how to perform the "reverse pd.get_dummies()"? What I would like to accomplish is given a dataframe df1 A B C...
ds1000_data_23
Problem: Given a pandas DataFrame, how does one convert several binary columns (where 1 denotes the value exists, 0 denotes it doesn't) into a single categorical column of lists? What I would like to accomplish is given a dataframe df1 A B C D 0 1 0 1 0 1 0 1 1 0 2 0 0 1 0 3 0 0 0 1 4 1 1 1 ...
ds1000_data_24
Problem: I have the following DF Date 0 2018-01-01 1 2018-02-08 2 2018-02-08 3 2018-02-08 4 2018-02-08 I want to extract the month name and year in a simple way in the following format: Date 0 Jan-2018 1 Feb-2018 2 Feb-2018 3 Feb-2018 4 Feb-2018 I have used the df.Date....
ds1000_data_25
Problem: I have the following DF Date 0 2018-01-01 1 2018-02-08 2 2018-02-08 3 2018-02-08 4 2018-02-08 I want to extract the month name and year and day in a simple way in the following format: Date 0 01-Jan-2018 1 08-Feb-2018 2 08-Feb-2018 3 08-Feb-2018 4 08-Feb-2018 I have use...
ds1000_data_26
Problem: I have the following DF Date 0 2018-01-01 1 2018-02-08 2 2018-02-08 3 2018-02-08 4 2018-02-08 I have another list of two date: [2017-08-17, 2018-01-31] For data between 2017-08-17 to 2018-01-31,I want to extract the month name and year and day in a simple way in the following format: ...
ds1000_data_27
Problem: So I have a dataframe that looks like this: #1 #2 1980-01-01 11.6985 126.0 1980-01-02 43.6431 134.0 1980-01-03 54.9089 130.0 1980-01-04 63.1225 126.0 ...
ds1000_data_28
Problem: So I have a dataframe that looks like this: #1 #2 1980-01-01 11.6985 126.0 1980-01-02 43.6431 134.0 1980-01-03 54.9089 130.0 1980-01-04 63.1225 126.0 ...
ds1000_data_29
Problem: So I have a dataframe that looks like this: #1 #2 1980-01-01 11.6985 126.0 1980-01-02 43.6431 134.0 1980-01-03 54.9089 130.0 1980-01-04 63.1225 126.0 ...
ds1000_data_30
Problem: So I have a dataframe that looks like this: #1 #2 1980-01-01 11.6985 126.0 1980-01-02 43.6431 134.0 1980-01-03 54.9089 130.0 1980-01-04 63.1225 126.0 ...
ds1000_data_31
Problem: Considering a simple df: HeaderA | HeaderB | HeaderC 476 4365 457 Is there a way to rename all columns, for example to add to all columns an "X" in the end? HeaderAX | HeaderBX | HeaderCX 476 4365 457 I am concatenating multiple dataframes and want to easily differentiate the...
ds1000_data_32
Problem: Considering a simple df: HeaderA | HeaderB | HeaderC 476 4365 457 Is there a way to rename all columns, for example to add to all columns an "X" in the head? XHeaderA | XHeaderB | XHeaderC 476 4365 457 I am concatenating multiple dataframes and want to easily differentiate the...
ds1000_data_33
Problem: Considering a simple df: HeaderA | HeaderB | HeaderC | HeaderX 476 4365 457 345 Is there a way to rename all columns, for example to add to columns which don’t end with "X" and add to all columns an "X" in the head? XHeaderAX | XHeaderBX | XHeaderCX | XHeaderX 476 4365 457...
ds1000_data_34
Problem: I have a script that generates a pandas data frame with a varying number of value columns. As an example, this df might be import pandas as pd df = pd.DataFrame({ 'group': ['A', 'A', 'A', 'B', 'B'], 'group_color' : ['green', 'green', 'green', 'blue', 'blue'], 'val1': [5, 2, 3, 4, 5], 'val2' : [4, 2, 8, 5, 7] ...
ds1000_data_35
Problem: I have a script that generates a pandas data frame with a varying number of value columns. As an example, this df might be import pandas as pd df = pd.DataFrame({ 'group': ['A', 'A', 'A', 'B', 'B'], 'group_color' : ['green', 'green', 'green', 'blue', 'blue'], 'val1': [5, 2, 3, 4, 5], 'val2' : [4, 2, 8, 5, 7] ...
ds1000_data_36
Problem: I have a script that generates a pandas data frame with a varying number of value columns. As an example, this df might be import pandas as pd df = pd.DataFrame({ 'group': ['A', 'A', 'A', 'B', 'B'], 'group_color' : ['green', 'green', 'green', 'blue', 'blue'], 'val1': [5, 2, 3, 4, 5], 'val2' : [4, 2, 8, 5, 7] ...
ds1000_data_37
Problem: I have pandas df with say, 100 rows, 10 columns, (actual data is huge). I also have row_index list which contains, which rows to be considered to take mean. I want to calculate mean on say columns 2,5,6,7 and 8. Can we do it with some function for dataframe object? What I know is do a for loop, get value of ro...
ds1000_data_38
Problem: I have pandas df with say, 100 rows, 10 columns, (actual data is huge). I also have row_index list which contains, which rows to be considered to take sum. I want to calculate sum on say columns 2,5,6,7 and 8. Can we do it with some function for dataframe object? What I know is do a for loop, get value of row ...
ds1000_data_39
Problem: I have pandas df with say, 100 rows, 10 columns, (actual data is huge). I also have row_index list which contains, which rows to be considered to take sum. I want to calculate sum on say columns 2,5,6,7 and 8. Can we do it with some function for dataframe object? What I know is do a for loop, get value of row ...
ds1000_data_40
Problem: I have a dataframe with numerous columns (≈30) from an external source (csv file) but several of them have no value or always the same. Thus, I would to see quickly the value_counts for each column. How can i do that? For example id, temp, name 1 34, null, mark 2 22, null, mark 3 34, null, mark Please retu...
ds1000_data_41
Problem: I have a dataframe with numerous columns (≈30) from an external source (csv file) but several of them have no value or always the same. Thus, I would to see quickly the counts of 'null' for each column. How can i do that? For example id, temp, name 1 34, null, null 2 22, null, mark 3 34, null, mark Please ...
ds1000_data_42
Problem: I have a dataframe with numerous columns (≈30) from an external source (csv file) but several of them have no value or always the same. Thus, I would to see quickly the value_counts for each column. How can i do that? For example id, temp, name 1 34, null, mark 2 22, null, mark 3 34, null, mark Please retur...
ds1000_data_43
Problem: I am trying to clean up a Excel file for some further research. Problem that I have, I want to merge the first and second row. The code which I have now: xl = pd.ExcelFile("nanonose.xls") df = xl.parse("Sheet1") df = df.drop('Unnamed: 2', axis=1) ## Tried this line but no luck ##print(df.head().combine_first(...
ds1000_data_44
Problem: I am trying to clean up a Excel file for some further research. Problem that I have, I want to merge the first and second row. The code which I have now: xl = pd.ExcelFile("nanonose.xls") df = xl.parse("Sheet1") df = df.drop('Unnamed: 2', axis=1) ## Tried this line but no luck ##print(df.head().combine_first(...
ds1000_data_45
Problem: I have a DataFrame like : 0 1 2 0 0.0 1.0 2.0 1 NaN 1.0 2.0 2 NaN NaN 2.0 What I want to get is Out[116]: 0 1 2 0 0.0 1.0 2.0 1 1.0 2.0 NaN 2 2.0 NaN NaN This is my approach as of now. df.apply(lambda x : (x[x.notnull()].values.tolist()+x[x.isnull()].values.tolist())...
ds1000_data_46
Problem: I have a DataFrame like : 0 1 2 0 0.0 1.0 2.0 1 1.0 2.0 NaN 2 2.0 NaN NaN What I want to get is Out[116]: 0 1 2 0 0.0 1.0 2.0 1 Nan 1.0 2.0 2 NaN NaN 2.0 This is my approach as of now. df.apply(lambda x : (x[x.isnull()].values.tolist()+x[x.notnull()].values.tolist())...
ds1000_data_47
Problem: I have a DataFrame like : 0 1 2 0 0.0 1.0 2.0 1 NaN 1.0 2.0 2 NaN NaN 2.0 What I want to get is Out[116]: 0 1 2 0 NaN NaN 2.0 1 NaN 1.0 2.0 2 0.0 1.0 2.0 This is my approach as of now. df.apply(lambda x : (x[x.isnull()].values.tolist()+x[x.notnull()].values.tolist())...
ds1000_data_48
Problem: I have a pandas dataframe structured like this: value lab A 50 B 35 C 8 D 5 E 1 F 1 This is just an example, the actual dataframe is bigger, but follows the same structure. The sample dataframe has been created with this two lines: df = pd.DataFrame...
ds1000_data_49
Problem: I have a pandas dataframe structured like this: value lab A 50 B 35 C 8 D 5 E 1 F 1 This is just an example, the actual dataframe is bigger, but follows the same structure. The sample dataframe has been created with this two lines: df = pd.DataFrame...
ds1000_data_50
Problem: I have a pandas dataframe structured like this: value lab A 50 B 35 C 8 D 5 E 1 F 1 This is just an example, the actual dataframe is bigger, but follows the same structure. The sample dataframe has been created with this two lines: df = pd.DataFrame(...
ds1000_data_51
Problem: Sample dataframe: df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) I'd like to add inverses of each existing column to the dataframe and name them based on existing column names with a prefix, e.g. inv_A is an inverse of column A and so on. The resulting dataframe should look like so: result = pd.DataFrame...
ds1000_data_52
Problem: Sample dataframe: df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) I'd like to add exponentials of each existing column to the dataframe and name them based on existing column names with a prefix, e.g. exp_A is an exponential of column A and so on. The resulting dataframe should look like so: result = pd.D...
ds1000_data_53
Problem: Sample dataframe: df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 0]}) I'd like to add inverses of each existing column to the dataframe and name them based on existing column names with a prefix, e.g. inv_A is an inverse of column A and so on. Notice that 0 has no inverse and please keep it in inv_A The resul...
ds1000_data_54
Problem: Sample dataframe: df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) I'd like to add sigmoids of each existing column to the dataframe and name them based on existing column names with a prefix, e.g. sigmoid_A is an sigmoid of column A and so on. The resulting dataframe should look like so: result = pd.DataF...
ds1000_data_55
Problem: The title might not be intuitive--let me provide an example. Say I have df, created with: a = np.array([[ 1. , 0.9, 1. ], [ 0.9, 0.9, 1. ], [ 0.8, 1. , 0.5], [ 1. , 0.3, 0.2], [ 1. , 0.2, 0.1], [ 0.9, 1. , 1. ], [ ...
ds1000_data_56
Problem: The title might not be intuitive--let me provide an example. Say I have df, created with: a = np.array([[ 1. , 0.9, 1. ], [ 0.9, 0.9, 1. ], [ 0.8, 1. , 0.5], [ 1. , 0.3, 0.2], [ 1. , 0.2, 0.1], [ 0.9, 1. , 1. ], [ ...
ds1000_data_57
Problem: I've a data frame that looks like the following x = pd.DataFrame({'user': ['a','a','b','b'], 'dt': ['2016-01-01','2016-01-02', '2016-01-05','2016-01-06'], 'val': [1,33,2,1]}) What I would like to be able to do is find the minimum and maximum date within the date column and expand that column to have all the ...
ds1000_data_58
Problem: I've a data frame that looks like the following x = pd.DataFrame({'user': ['abc','abc','efg','efg'], 'dt': ['2022-01-01','2022-01-02', '2022-01-05','2022-01-06'], 'val': [1,14,51,4]}) What I would like to be able to do is find the minimum and maximum date within the date column and expand that column to have...
ds1000_data_59
Problem: I've a data frame that looks like the following x = pd.DataFrame({'user': ['a','a','b','b'], 'dt': ['2016-01-01','2016-01-02', '2016-01-05','2016-01-06'], 'val': [1,33,2,1]}) What I would like to be able to do is find the minimum and maximum date within the date column and expand that column to have all the ...
ds1000_data_60
Problem: I've a data frame that looks like the following x = pd.DataFrame({'user': ['a','a','b','b'], 'dt': ['2016-01-01','2016-01-02', '2016-01-05','2016-01-06'], 'val': [1,33,2,1]}) What I would like to be able to do is find the minimum and maximum date within the date column and expand that column to have all the ...
ds1000_data_61
Problem: I've a data frame that looks like the following x = pd.DataFrame({'user': ['a','a','b','b'], 'dt': ['2016-01-01','2016-01-02', '2016-01-05','2016-01-06'], 'val': [1,33,2,1]}) What I would like to be able to do is find the minimum and maximum date within the date column and expand that column to have all the ...
ds1000_data_62
Problem: I am using Pandas to get a dataframe like this: name a b c 0 Aaron 3 5 7 1 Aaron 3 6 9 2 Aaron 3 6 10 3 Brave 4 6 0 4 Brave 3 6 1 I want to replace each name with a unique ID so output looks like: name a b c 0 1 3 5 7 1 1 3 6 9 2 1 3 6 10 3 2 4 6...
ds1000_data_63
Problem: I am using Pandas to get a dataframe like this: name a b c 0 Aaron 3 5 7 1 Aaron 3 6 9 2 Aaron 3 6 10 3 Brave 4 6 0 4 Brave 3 6 1 5 David 5 1 4 I want to replace each a with a unique ID so output looks like: name a b c 0 Aaron 1 5 7 1 Aaron 1 6 9 2 Aaron...
ds1000_data_64
Problem: I am using Pandas to get a dataframe like this: name a b c 0 Aaron 3 5 7 1 Aaron 3 6 9 2 Aaron 3 6 10 3 Brave 4 6 0 4 Brave 3 6 1 I want to replace each name with a unique ID so output looks like: name a b c 0 1 3 5 7 1 1 3 6 9 2 1 3 6 10 3 2 4 6...
ds1000_data_65
Problem: I am using Pandas to get a dataframe like this: name a b c 0 Aaron 3 5 7 1 Aaron 3 6 9 2 Aaron 3 6 10 3 Brave 4 6 0 4 Brave 3 6 1 I want to combine name and a and replace each of them with a unique ID so output looks like: ID b c 0 1 5 7 1 1 6 9 2 1 6 10 ...
ds1000_data_66
Problem: I have a table like this. user 01/12/15 02/12/15 someBool u1 100 300 True u2 200 -100 False u3 -50 200 True I want to repartition the date columns into two columns date and value like this. user date value someBool u1 01/12/15 100 ...
ds1000_data_67
Problem: I have a table like this. user 01/12/15 02/12/15 someBool u1 100 300 True u2 200 -100 False u3 -50 200 True I want to repartition the others columns into two columns others and value like this. user 01/12/15 others value 0 u1 100 02/1...
ds1000_data_68
Problem: I have a table like this. user 01/12/15 02/12/15 someBool u1 100 None True u2 200 -100 False u3 None 200 True I want to repartition the date columns into two columns date and value like this. user date value someBool u1 01/12/15 100...
ds1000_data_69
Problem: I'm wondering if there is a simpler, memory efficient way to select a subset of rows and columns from a pandas DataFrame. For instance, given this dataframe: df = DataFrame(np.random.rand(4,5), columns = list('abcde')) print df a b c d e 0 0.945686 0.000710 0....
ds1000_data_70
Problem: I'm wondering if there is a simpler, memory efficient way to select a subset of rows and columns from a pandas DataFrame. For instance, given this dataframe: df = DataFrame(np.random.rand(4,5), columns = list('abcde')) print df a b c d e 0 0.945686 0.000710 0....
ds1000_data_71
Problem: I'm wondering if there is a simpler, memory efficient way to select a subset of rows and columns from a pandas DataFrame. For instance, given this dataframe: df = DataFrame(np.random.rand(4,5), columns = list('abcde')) print df a b c d e 0 0.945686 0.000710 0....
ds1000_data_72
Problem: I'm wondering if there is a simpler, memory efficient way to select a subset of rows and columns from a pandas DataFrame, then compute and append sum of the two columns for each element to the right of original columns. For instance, given this dataframe: df = DataFrame(np.random.rand(4,5), columns = lis...
ds1000_data_73
Problem: I'm wondering if there is a simpler, memory efficient way to select a subset of rows and columns from a pandas DataFrame. For instance, given this dataframe: df = DataFrame(np.random.rand(4,5), columns = list('abcde')) print df a b c d e 0 0.945686 0.000710 0....
ds1000_data_74
Problem: I have a pandas dataframe that looks like the following: ID date close 1 09/15/07 123.45 2 06/01/08 130.13 3 10/25/08 132.01 4 05/13/09 118.34 5 11/07/09 145.99 6 11/15/09 146.73 7 07/03/11 171.10 I want to remove any rows that overlap. Overlapping rows is defined as any ...
ds1000_data_75
Problem: I have a pandas dataframe that looks like the following: ID date close 1 09/15/07 123.45 2 06/01/08 130.13 3 10/25/08 132.01 4 05/13/09 118.34 5 11/07/09 145.99 6 11/15/09 146.73 7 07/03/11 171.10 I want to remove any rows that overlap. Overlapping rows is defined as any ...
ds1000_data_76
Problem: I have a pandas dataframe that looks like the following: ID date close 1 09/15/07 123.45 2 06/01/08 130.13 3 10/25/08 132.01 4 05/13/09 118.34 5 11/07/09 145.99 6 11/15/09 146.73 7 07/03/11 171.10 I want to remove any rows that overlapand convert df to the following format:...
ds1000_data_77
Problem: I have a simple dataframe which I would like to bin for every 3 rows. It looks like this: col1 0 2 1 1 2 3 3 1 4 0 and I would like to turn it into this: col1 0 2 1 0.5 I have already posted a similar question here but I have no Idea how to port the solution to my...
ds1000_data_78
Problem: I have a simple dataframe which I would like to bin for every 3 rows. It looks like this: col1 0 1 1 1 2 4 3 5 4 1 and I would like to turn it into this: col1 0 2 1 3 I have already posted a similar question here but I have no Idea how to port the solution to my...
ds1000_data_79
Problem: I have a simple dataframe which I would like to bin for every 4 rows. It looks like this: col1 0 1 1 1 2 4 3 5 4 1 5 4 and I would like to turn it into this: col1 0 11 1 5 I have already posted a similar question here but I have no Idea how to port the solut...
ds1000_data_80
Problem: I have a simple dataframe which I would like to bin for every 3 rows from back to front. It looks like this: col1 0 2 1 1 2 3 3 1 4 0 and I would like to turn it into this: col1 0 1.5 1 1.333 I have already posted a similar question here but I have no Idea how to po...
ds1000_data_81
Problem: I have a simple dataframe which I would like to bin for every 3 rows to get sum and 2 rows to get avg.That means for the first 3 rows get their sum, then 2 rows get their avg, then 3 rows get their sum, then 2 rows get their avg… It looks like this: col1 0 2 1 1 2 3 3 1 4 0 5 ...
ds1000_data_82
Problem: I have a simple dataframe which I would like to bin for every 3 rows to get sum and 2 rows to get avg from end to head.That means for the last 3 rows get their sum, then 2 rows get their avg, then 3 rows get their sum, then 2 rows get their avg… It looks like this: col1 0 2 1 1 2 3 3 ...
ds1000_data_83
Problem: I have the following dataframe: index = range(14) data = [1, 0, 0, 2, 0, 4, 6, 8, 0, 0, 0, 0, 2, 1] df = pd.DataFrame(data=data, index=index, columns = ['A']) How can I fill the zeros with the previous non-zero value using pandas? Is there a fillna that is not just for "NaN"?. The output should look like: ...
ds1000_data_84
Problem: I have the following dataframe: index = range(14) data = [1, 0, 0, 2, 0, 4, 6, 8, 0, 0, 0, 0, 2, 1] df = pd.DataFrame(data=data, index=index, columns = ['A']) How can I fill the zeros with the posterior non-zero value using pandas? Is there a fillna that is not just for "NaN"?. The output should look like:...
ds1000_data_85
Problem: I have the following dataframe: index = range(14) data = [1, 0, 0, 2, 0, 4, 6, 8, 0, 0, 0, 0, 2, 1] df = pd.DataFrame(data=data, index=index, columns = ['A']) How can I fill the zeros with the maximun between previous and posterior non-zero value using pandas? Is there a fillna that is not just for "NaN"?. ...
ds1000_data_86
Problem: This is my data frame index duration 1 7 year 2 2day 3 4 week 4 8 month I need to separate numbers from time and put them in two new columns. I also need to create another column based on the values of time column. So the new dataset is like this: index d...
ds1000_data_87
Problem: This is my data frame duration 1 year 7 2 day2 3 week 4 4 month 8 I need to separate numbers from time and put them in two new columns. I also need to create another column based on the values of time column. So the new dataset is like this: duration time number time_day 1 year 7 year ...
ds1000_data_88
Problem: This is my data frame index duration 1 7 year 2 2day 3 4 week 4 8 month I need to separate numbers from time and put them in two new columns. I also need to create another column based on the values of time column. So the new dataset is like this: index d...
ds1000_data_89
Problem: This is my data frame duration 1 year 7 2 day2 3 week 4 4 month 8 I need to separate numbers from time and put them in two new columns. I also need to create another column based on the values of time column. So the new dataset is like this: duration time number time_day 1 year 7 year ...
ds1000_data_90
Problem: I am aware there are many questions on the topic of chained logical operators using np.where. I have 2 dataframes: df1 A B C D E F Postset 0 1 2 3 4 5 6 yes 1 1 2 3 4 5 6 no 2 1 2 3 4 5 6 yes df2 A B C D E F Preset 0 1 2 3 4 5 6 yes 1 1 2 3 4 5 6 ...
ds1000_data_91
Problem: I am aware there are many questions on the topic of chained logical operators using np.where. I have 2 dataframes: df1 A B C D E F Postset 0 1 2 3 4 5 6 yes 1 1 2 3 4 5 6 no 2 1 2 3 4 5 6 yes df2 A B C D E F Preset 0 1 2 3 4 5 6 yes 1 1 2 3 4 5 6 ...
ds1000_data_92
Problem: I have multi-index df as follows x y id date abc 3/1/1994 100 7 9/1/1994 90 8 3/1/1995 80 9 Where dates are stored as str. I want to parse date index. The following statement df.index.levels[1] = pd.to_datetime(df.index.levels[1]) returns error: TypeError: ...
ds1000_data_93
Problem: I have multi-index df as follows fee credits name datetime abc 3/1/1994 100 7 9/1/1994 90 8 3/1/1995 80 9 Where dates are stored as str. I want to parse datetimw index. The following statement df.index.levels[1] = pd.to_datetime(df.index.levels[1]) re...
ds1000_data_94
Problem: I have multi-index df as follows x y id date abc 3/1/1994 100 7 9/1/1994 90 8 3/1/1995 80 9 Where dates are stored as str. I want to parse date index, and I want a numpy array of date, x and y as the output. Any help would be appreciated. desired output: [[Time...
ds1000_data_95
Problem: I have multi-index df as follows x y date id 3/1/1994 abc 100 7 9/1/1994 abc 90 8 3/1/1995 abc 80 9 Where dates are stored as str. I want to parse date index using pd.to_datetime, and swap the two levels. The final output should be x y id ...
ds1000_data_96
Problem: I have a data set which is in wide format like this Index Country Variable 2000 2001 2002 2003 2004 2005 0 Argentina var1 12 15 18 17 23 29 1 Argentina var2 1 3 2 5 7 5 2 Brazil var1 20 23 25 29 31 32 3 Brazil var2 ...
ds1000_data_97
Problem: I have a data set which is in wide format like this Index Country Variable 2000 2001 2002 2003 2004 2005 0 Argentina var1 12 15 18 17 23 29 1 Argentina var2 1 3 2 5 7 5 2 Brazil var1 20 23 25 29 31 32 3 Brazil var2 ...
ds1000_data_98
Problem: I have a data frame like below A_Name B_Detail Value_B Value_C Value_D ...... 0 AA X1 1.2 0.5 -1.3 ...... 1 BB Y1 0.76 -0.7 0.8 ...... 2 CC Z1 0.7 -1.3 2.5 ...... 3 DD L1 0.9 -0.5 0.4 .........
ds1000_data_99
Problem: I have a data frame like below A_Name B_Detail Value_B Value_C Value_D ...... 0 AA X1 1.2 0.5 -1.3 ...... 1 BB Y1 0.76 -0.7 0.8 ...... 2 CC Z1 0.7 -1.3 2.5 ...... 3 DD L1 0.9 -0.5 0.4 .........
ds1000_data_100
Problem: I have a data frame like below A_Name B_Detail Value_B Value_C Value_D ...... 0 AA X1 1.2 0.5 -1.3 ...... 1 BB Y1 0.76 -0.7 0.8 ...... 2 CC Z1 0.7 -1.3 2.5 ...... 3 DD L1 0.9 -0.5 0.4 .........