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. ],
[ ... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 7