I want to extract only the data from Excel in Excel by specifying conditions.
Then I want to write the extracted data to Excel.
In the middle of that, I was trying to create a data frame with Pandas, and when I tried to change the data to Excel and assign a column name in the data frame definition part, the following error message occurred. It is written in the part of # that i am trying to do, but please also see if the code matches it.
Applicable source code
The truth value of a Series is ambiguous.Use a.empty, a.bool (), a.item (), a.any () or a.all ().
import pandas as pd df_A = pd.read_excel ("pandas_practice.xlsx", sheet_name = "Sheet1", index_col = [0,1]) # pd.read_excel (EXCEL file name, sheet_name = sheet name, index_col = column name/column number specified for index) Columns1 = ["CogDeg", "i", "j", "L", "B", "V"] #Column name df_B = pd.DataFrame (data = df_A, columns = Columns1) #Create a data frame with a named column df_C = df_B [df_B ["i"] == 0 and df_B ["j"] == 0] # Extract all rows where both column names i and j are 0 from the data frame df_C = pd.to_excel ("C: \ Desktop \ Python \ pandas_practice.xlsx", sheet_name = "Sheet2") # pd.to_excel (Destination directory + EXCEL file name, sheet_name = Sheet name)
I didn't understand even after examining it.Supplemental information (FW/tool version etc.)
Please provide more detailed information here.
Answer # 1
df_C = df_B [df_B ["i"] == 0 and df_B ["j"] == 0]
part is incorrect.
df_C = df_B [(df_B ["i"] == 0)&(df_B ["j"] == 0)]
[Python] Dealing with errors when multiple conditions are specified in pandas.DataFrame-Qiita
What to do when an error like The truth value of ... is ambiguous. occurs in numpy or pandas-A quiet name (拙 Article)
Answer # 2
☓ df_C = pd.to_excel (.. ....
◯ df_C.to_excel (......
- python - i want to sort and extract the top n columns for each "dataframe" index
- about the operation of excel using python
- python - excel display format using pyhon does not work
- line breaks when outputting to excel in python
- about external libraries when using multiple versions of python
- python - i want to separate by a specific word using the split function
- python - image recognition using cnn keras multiple inputs
- python3 extract and delete duplicate data of date and time
- about batch change of file name using python
- extract title and video count with python youtube api
- python 3x - i want to get the nth array with an argument using python3 argparse
- excel python i want to get the display result instead of the conditional statement
- python 3x - how to rename a folder created using jupyternotebook
- csv - i want to extract the numerical group of the excel file displayed in matlab as it is
- python - pandasdataframe i want to match the time columns of two csv and load them
- python 3x - processing to jump to the link destination using chrome driver in python
- python - error in image binarization using cv2adaptivethreshold function
- python - i want to extract the numerical value at a certain position from bs4elementtab extracted by beautifulsoup by using the
- parameter estimation using python's weighted least squares method (wls)
- extract from python dat data and output to csv
- if the integer in the table created by dataframe and the ejected integer are the same, i want to make a conditional branch
- python 3x - why the element extracted from the list is dtaframe
- python 3x - dataframe column labels are unchanged
- python 3x - pandas: about line feed characters when outputting txt
- for - how to create a table in python that shows all the experimental combinations
- python - about the process of extracting the canceled data based on the absolute value in the data frame
- python 3x - how to extract data that meets the value conditions from another data frame based on the value of one data frame
- python 3x - i get lost when extracting columns in a dataframe
- python 3x - pandas matrix summary table insert columns
- python 3x - pandas: i want to normalize the result aggregated by pivot_table