Python | Read csv using pandas.read_csv() - GeeksforGeeks
文章推薦指數: 80 %
To access data from the CSV file, we require a function read_csv() that retrieves data in the form of the Dataframe. Skiptocontent CoursesGeekWeek2022ForWorkingProfessionalsDSAClasses(Live)SystemDesign(Live)JavaBackendDeveloper(Live)FullStack(Live)ExploreMoreLiveCoursesDSA(Self-Paced)SDETheory(Self-Paced)AllDevelopmentCourses(Self-Paced)ExploreMoreSelf-PacedCoursesForStudentsCompetitiveProgramming(Live)GATECourse2023(Live)DataScience(Live)ExploreMoreLiveCoursesDSA(Self-Paced)CIP(Self-Paced)JAVA/Python/C++(Self-Paced)ExploreMoreSelf-PacedCoursesSchoolCoursesSchoolGuidePythonProgrammingLearnToMakeAppsExploremoreAllCoursesTutorialsAlgorithmsAnalysisofAlgorithmsAsymptoticAnalysisWorst,AverageandBestCasesAsymptoticNotationsLittleoandlittleomeganotationsLowerandUpperBoundTheoryAnalysisofLoopsSolvingRecurrencesAmortizedAnalysisWhatdoes'SpaceComplexity'mean?Pseudo-polynomialAlgorithmsPolynomialTimeApproximationSchemeATimeComplexityQuestionSearchingAlgorithmsSortingAlgorithmsGraphAlgorithmsPatternSearchingGeometricAlgorithmsMathematicalBitwiseAlgorithmsRandomizedAlgorithmsGreedyAlgorithmsDynamicProgrammingDivideandConquerBacktrackingBranchandBoundAllAlgorithmsDataStructuresArraysLinkedListStackQueueBinaryTreeBinarySearchTreeHeapHashingGraphAdvancedDataStructureMatrixStringsAllDataStructuresInterviewCornerCompanyPreparationTopTopicsPracticeCompanyQuestionsInterviewExperiencesExperiencedInterviewsInternshipInterviewsCompetititveProgrammingDesignPatternsSystemDesignTutorialMultipleChoiceQuizzesLanguagesCC++JavaPythonC#SQLScalaPerlGoLanguageKotlinWebDevelopmentHTMLCSSJavaScriptPHPCSSFrameworksBootstrapTailwindCSSFoundationCSSMaterializeCSSBulmaPureCSSPrimerCSSBlazeUISemanticUIJavaScriptFrameworksAngularJSNodeJSJavaScriptLibrariesjQueryReactJSML&DataScienceMachineLearningDataScienceCSSubjectsMathematicsOperatingSystemDBMSComputerNetworksComputerOrganizationandArchitectureTheoryofComputationCompilerDesignDigitalLogicSoftwareEngineeringGATEGATEComputerScienceNotesLastMinuteNotesGATECSSolvedPapersGATECSOriginalPapersandOfficialKeysGATE2021DatesGATECS2021SyllabusImportantTopicsforGATECSSoftwareDesignsSoftwareDesignPatternsSystemDesignTutorialGFGSheetsWebDevCheatSheetsHTMLCheatSheetCSSCheatSheetJSCheatSheetjQueryCheatSheetCompany-WiseSDESheetsFacebookSDESheetAmazonSDESheetAppleSDESheetNetflixSDESheetGoogleSDESheetWiproCodingSheetInfosysCodingSheetTCSCodingSheetCognizantCodingSheetHCLCodingSheetDSASheetsSDESheetFAANGCodingSheetLoveBabbarSheetMassRecruiterSheetProduct-BasedCodingSheetCompany-WisePreparationSheetArraySheetStringSheetTreeSheetGraphSheetDPSheetSchoolLearningSchoolProgrammingMathematicsNumberSystemAlgebraTrigonometryStatisticsProbabilityGeometryMensurationCalculusMathsNotes(Class8-12)Class8NotesClass9NotesClass10NotesClass11NotesClass12NotesNCERTSolutionsClass8MathsSolutionClass9MathsSolutionClass10MathsSolutionClass11MathsSolutionClass12MathsSolutionRDSharmaSolutionsClass8MathsSolutionClass9MathsSolutionClass10MathsSolutionClass11MathsSolutionClass12MathsSolutionPhysicsNotes(Class8-11)Class8NotesClass9NotesClass10NotesClass11NotesChemistryNotesClass8NotesClass9NotesClass10NotesBusinessStudies(Class11th)BusinessStudies(Class12th)CSExams/PSUsISROISROCSOriginalPapersandOfficialKeysISROCSSolvedPapersISROCSSyllabusforScientist/EngineerExamUGCNETUGCNETCSNotesPaperIIUGCNETCSNotesPaperIIIUGCNETCSSolvedPapersStudentCampusAmbassadorProgramSchoolAmbassadorProgramProjectGeekoftheMonthCampusGeekoftheMonthPlacementCourseCompetititveProgrammingTestimonialsStudentChapterGeekontheTopInternshipCareersUPSCGeographyNotesHistoryNotesScience&Tech.NotesEthicsNotesPolityNotesEconomicsNotesUPSCPreviousYearPapersSSCCGLSSCCGLSyllabusGeneralStudiesEnglishReasoningSubjectwisePracticePapersPreviousYearPapersBankingExamsSBIClerkSBIClerkSyllabusGeneralAwarenessEnglishQuantitativeAptitudeReasoningAbilitySBIClerkPracticePapersSBIPOSBIPOSyllabusGeneralAwarenessEnglishQuantitativeAptitudeReasoningAbilityPreviousYearPapersSBIPOPracticePapersIBPSPOIBPSPO2022SyllabusEnglishNotesReasoningNotesPreviousYearPapersMockQuestionPapersIBPSClerkIBPSClerkSyllabusEnglishNotesPreviousYearPapersJobsApplyforJobsPostaJobHirewithUsKnowaboutJobathonJobathonPracticeAllDSAProblemsProblemoftheDayInterviewSeries:WeeklyContestsBi-WizardCoding:SchoolContestsEventsPracticeSDESheetCuratedDSAListsTop50ArrayProblemsTop50StringProblemsTop50TreeProblemsTop50GraphProblemsTop50DPProblemsContests HomeSavedVideosCoursesGBlogPuzzlesWhat'sNew? ChangeLanguage DataStructuresAlgorithmsInterviewPreparationTopic-wisePracticeC++JavaPythonCompetitiveProgrammingMachineLearningJavaScriptSDESheetPuzzlesGFGSchoolProjects RelatedArticles ▲RelatedArticlesIntroductionPythonProgrammingLanguageIntroductionToPYTHONPythonLanguageadvantagesandapplicationsDownloadandInstallPython3LatestVersionPython3basicsPythonKeywordsNamespacesandScopeinPythonStatement,IndentationandCommentinPythonHowtoassignvaluestovariablesinPythonandotherlanguagesInput/OutputTakinginputinPythonTakinginputfromconsoleinPythonTakingmultipleinputsfromuserinPythonPython|Outputusingprint()functionHowtoprintwithoutnewlineinPython?Pythonendparameterinprint()Python|sepparameterinprint()Python|OutputFormattingOperatorsPythonOperatorsTernaryOperatorinPythonDivisionOperatorsinPythonOperatorOverloadinginPythonAnyAllinPythonOperatorFunctionsinPython|Set1OperatorFunctionsinPython|Set2Differencebetween==andisoperatorinPythonPythonMembershipandIdentityOperatorsDataTypesPython|Set3(Strings,Lists,Tuples,Iterations)PythonStringPythonListsPythonTuplesPythonSetsPythonDictionaryPythonArraysControlFlowControlFlowinPythonChainingcomparisonoperatorsinPythonPythonForLoopsPythonWhileLoopPythonbreakstatementPythonContinueStatementPythonpassStatementLoopingTechniquesinPythonFunctionsPythonFunctions*argsand**kwargsinPythonWhentouseyieldinsteadofreturninPython?GeneratorsinPythonPythonlambdaGlobalandLocalVariablesinPythonGlobalkeywordinPythonFirstClassfunctionsinPythonPythonClosuresDecoratorsinPythonDecoratorswithparametersinPythonMemoizationusingdecoratorsinPythonPythonOOPPythonClassesandObjectsConstructorsinPythonDestructorsinPythonInheritanceinPythonTypesofinheritancePythonEncapsulationinPythonPolymorphisminPythonClassorStaticVariablesinPythonClassmethodvsStaticmethodinPythonExceptionHandlingPythonExceptionHandlingPythonTryExceptErrorsandExceptionsinPythonBuilt-inExceptionsinPythonUser-definedExceptionsinPythonwithExamplesNZECerrorinPythonFilehandlingFileHandlinginPythonOpenaFileinPythonHowtoreadfromafileinPythonWritingtofileinPythonPythonappendtoafilePythonRegexRegularExpressioninPythonwithExamples|Set1RegularExpressionsinPython–Set2(Search,MatchandFindAll)PythonRegex:re.search()VSre.findall()VerboseinPythonRegexPasswordvalidationinPythonPythonCollectionsPythonCollectionsModuleCountersinPython|Set1(InitializationandUpdation)OrderedDictinPythonDefaultdictinPythonChainMapinPythonNamedtupleinPythonDequeinPythonHeapqueue(orheapq)inPythonCollections.UserDictinPythonCollections.UserListinPythonCollections.UserStringinPythonPythonAdvanceOSModuleinPythonwithExamplesFunctionalProgramminginPythonMetaprogrammingwithMetaclassesinPythonAbstractClassesinPythonMultithreadinginPython|Set1MultithreadinginPython|Set2(Synchronization)MultiprocessinginPython|Set1(Introduction)MultiprocessinginPython|Set2(Communicationbetweenprocesses)SocketProgramminginPythonSocketProgrammingwithMulti-threadinginPythonPythonNumPyNumPyTutorialPythonNumpyNumpy|ndarrayNumpy|ArrayCreationNumpy|IndexingBasicSlicingandAdvancedIndexinginNumPyPythonNumpy|DataTypeObjectsNumpy|IteratingOverArrayNumpy|BinaryOperationsNumpy|MathematicalFunctionNumpy|StringOperationsNumpy|LinearAlgebraNumpy|Sorting,SearchingandCountingRandomsamplinginnumpy|randint()functionRandomsamplinginnumpy|random_sample()functionRandomsamplinginnumpy|ranf()functionRandomsamplinginnumpy|random_integers()functionNumpyufunc|UniversalfunctionsPythonPandasPandasTutorialIntroductiontoPandasinPythonHowtoInstallPythonPandasonWindowsandLinux?Python|PandasDataFrameCreatingaPandasDataFramePython|PandasSeriesCreatingaPandasSeriesPython|PandasDataframe/Series.head()methodPython|PandasDataframe.describe()methodDealingwithRowsandColumnsinPandasDataFramePython|PandasExtractingrowsusing.loc[]Python|ExtractingrowsusingPandas.iloc[]IndexingandSelectingDatawithPandasBooleanIndexinginPandasPandasGroupByPython|PandasMerging,Joining,andConcatenatingPython|WorkingwithdateandtimeusingPandasPython|PandasWorkingWithTextDataPython|Readcsvusingpandas.read_csv()Python|WorkingwithPandasandXlsxWriter|Set–1PythonDjangoDjangoTutorialDjangoBasicsDjangoIntroductionandInstallationDjangoProjectMVTStructureHowtoCreateaBasicProjectusingMVTinDjango?HowtoCreateanAppinDjango?DjangoFormsRenderHTMLForms(GET&POST)inDjangoDjangoformfieldcustomwidgetsDjangoModelForm–CreateformfromModelsDjangoFormsetsDjangoModelFormSetsDjangoTemplatesViewsInDjango|PythonDjangoCRUD(Create,Retrieve,Update,Delete)FunctionBasedViewsClassBasedGenericViewsDjango(Create,Retrieve,Update,Delete)DjangoModelsDjangoORM–Inserting,Updating&DeletingDataDjangoBasicAppModel–MakemigrationsandMigratePythonJSONPythonJSONWorkingWithJSONDatainPythonRead,WriteandParseJSONusingPythonAppendtoJSONfileusingPythonSerializingJSONdatainPythonDeserializeJSONtoObjectinPythonPythonCSVWorkingwithcsvfilesinPythonReadingCSVfilesinPythonWritingCSVfilesinPythonPythonMySQLPythonMySQLConnectMySQLdatabaseusingMySQL-ConnectorPythonPythonMySQL–CreateDatabasePython:MySQLCreateTablePythonMySQL–InsertintoTablePythonMySQL–SelectQueryPythonMySQL–WhereClausePythonMySQL–OrderByClausePythonMySQL–DeleteQueryPythonMySQL–DropTablePythonMySQL–UpdateQueryPythonMySQL–LimitClausePythonMySQL–JoinPythonMongoDBPythonMongoDBTutorialInstallingMongoDBonWindowswithPythonMongoDBandPythonCreateadatabaseinMongoDBusingPythonPythonMongoDB–insert_oneQueryPythonMongoDB–insert_manyQueryPythonMongoDB–FindPythonMongoDB–QueryPythonMongoDB–SortMongoDBpython|DeleteDataandDropCollectionPythonMongodb–Delete_one()PythonMongodb–Delete_many()PythonMongoDB–Update_one()PythonMongoDB–Update_manyQueryPythonMongoDB–LimitQueryPythonMongoDB–create_indexQueryPythonMongoDB–drop_indexQueryPythonOpenCVOpenCVPythonTutorialIntroductiontoOpenCVHowtoInstallOpenCVforPythononWindows?ReadinganimageinOpenCVusingPythonOpenCV|SavinganImageArithmeticOperationsonImagesusingOpenCV|Set-1(AdditionandSubtraction)ArithmeticOperationsonImagesusingOpenCV|Set-2(BitwiseOperationsonBinaryImages)ImageResizingusingOpenCV|PythonImageProcessinginPython(Scaling,Rotating,ShiftingandEdgeDetection)Python|ImageblurringusingOpenCVErosionandDilationofimagesusingOpenCVinpythonPython|ThresholdingtechniquesusingOpenCV|Set-1(SimpleThresholding)Python|ThresholdingtechniquesusingOpenCV|Set-2(AdaptiveThresholding)Python|ThresholdingtechniquesusingOpenCV|Set-3(OtsuThresholding)FilterColorwithOpenCVPython|BilateralFilteringPython|BackgroundsubtractionusingOpenCVPython|PlayavideousingOpenCVExtractimagesfromvideoinPythonFaceDetectionusingPythonandOpenCVwithwebcamPythonSeleniumSeleniumPythonTutorialSeleniumBasics–Components,Features,UsesandLimitationsComponentsofSeleniumSeleniumPythonIntroductionandInstallationNavigatinglinksusinggetmethod–SeleniumPythonInteractingwithWebpage–SeleniumPythonLocatingsingleelementsinSeleniumPythonLocatingmultipleelementsinSeleniumPythonLocatorStrategies–SeleniumPythonActionChainsinSeleniumPythonExceptions–SeleniumPythonPythonTkinterPythonTkinterTutorialIntroductiontoTkinterWhatareWidgetsinTkinter?Python|CreatingabuttonintkinterPythonTkinter–LabelRadioButtoninTkinter|PythonPythonTkinter–CheckbuttonWidgetPythonTkinter–CanvasWidgetComboboxWidgetintkinter|PythonPythonTkinter–EntryWidgetPythonTkinter–TextWidgetPythonTkinter–MessagePython|MenuwidgetinTkinterPythonTkinter–SpinBoxProgressbarwidgetinTkinter|PythonPython-TkinterScrollbarPythonTkinter–ScrolledTextWidgetPythonTkinter–ListBoxWidgetPythonTkinter–FrameWidgetPythonTkinter–ScaleWidgetHierarchicaltreeviewinPythonGUIapplicationPython-TkinterTreeviewscrollbarPythonTkinter–ToplevelWidgetPython|askopenfile()functioninTkinterPython|asksaveasfile()functioninTkinterPython–TkinteraskquestionDialogPythonTkinter–MessageBoxWidgetPython|place()methodinTkinterPython|grid()methodinTkinterPython|pack()methodinTkinterPython|PanedWindowWidgetinTkinterPython|BindingfunctioninTkinterPythonTkinter–ValidatingEntryWidgetPythonKivyKivyTutorialIntroductiontoKivy;ACross-platformPythonFrameworkPython|AddLabeltoakivywindowPython|TextinputwidgetinkivyPython|CanvasinkivyPython|CheckboxwidgetinKivyPython|DropdownlistinkivyPython|CarouselWidgetInKivyPython|BoxLayoutwidgetinKivyPython|SliderwidgetinKivyPython|PopupwidgetinKivyPython|SwitchwidgetinKivyPython|SpinnerwidgetinkivyPython|ProgressBarwidgetinkivyPython|WorkingwithbuttonsinKivyPython|FloatLayoutinKivyGridLayoutsinKivy|PythonPython|StackLayoutinKivyPython|AnchorLayoutinKivyPython|RelativeLayoutinKivyPython|PageLayoutinKivyDataVisualizationMatplotlibTutorialPythonSeabornTutorialPythonPlotlytutorialPythonBokehtutorial–InteractiveDataVisualizationwithBokehTableauTutorialPythonExamplesandQuizPythonProgrammingExamplesPythonExercises,PracticeQuestionsandSolutionsPythonMultipleChoiceQuestionsIntroductionPythonProgrammingLanguageIntroductionToPYTHONPythonLanguageadvantagesandapplicationsDownloadandInstallPython3LatestVersionPython3basicsPythonKeywordsNamespacesandScopeinPythonStatement,IndentationandCommentinPythonHowtoassignvaluestovariablesinPythonandotherlanguagesInput/OutputTakinginputinPythonTakinginputfromconsoleinPythonTakingmultipleinputsfromuserinPythonPython|Outputusingprint()functionHowtoprintwithoutnewlineinPython?Pythonendparameterinprint()Python|sepparameterinprint()Python|OutputFormattingOperatorsPythonOperatorsTernaryOperatorinPythonDivisionOperatorsinPythonOperatorOverloadinginPythonAnyAllinPythonOperatorFunctionsinPython|Set1OperatorFunctionsinPython|Set2Differencebetween==andisoperatorinPythonPythonMembershipandIdentityOperatorsDataTypesPython|Set3(Strings,Lists,Tuples,Iterations)PythonStringPythonListsPythonTuplesPythonSetsPythonDictionaryPythonArraysControlFlowControlFlowinPythonChainingcomparisonoperatorsinPythonPythonForLoopsPythonWhileLoopPythonbreakstatementPythonContinueStatementPythonpassStatementLoopingTechniquesinPythonFunctionsPythonFunctions*argsand**kwargsinPythonWhentouseyieldinsteadofreturninPython?GeneratorsinPythonPythonlambdaGlobalandLocalVariablesinPythonGlobalkeywordinPythonFirstClassfunctionsinPythonPythonClosuresDecoratorsinPythonDecoratorswithparametersinPythonMemoizationusingdecoratorsinPythonPythonOOPPythonClassesandObjectsConstructorsinPythonDestructorsinPythonInheritanceinPythonTypesofinheritancePythonEncapsulationinPythonPolymorphisminPythonClassorStaticVariablesinPythonClassmethodvsStaticmethodinPythonExceptionHandlingPythonExceptionHandlingPythonTryExceptErrorsandExceptionsinPythonBuilt-inExceptionsinPythonUser-definedExceptionsinPythonwithExamplesNZECerrorinPythonFilehandlingFileHandlinginPythonOpenaFileinPythonHowtoreadfromafileinPythonWritingtofileinPythonPythonappendtoafilePythonRegexRegularExpressioninPythonwithExamples|Set1RegularExpressionsinPython–Set2(Search,MatchandFindAll)PythonRegex:re.search()VSre.findall()VerboseinPythonRegexPasswordvalidationinPythonPythonCollectionsPythonCollectionsModuleCountersinPython|Set1(InitializationandUpdation)OrderedDictinPythonDefaultdictinPythonChainMapinPythonNamedtupleinPythonDequeinPythonHeapqueue(orheapq)inPythonCollections.UserDictinPythonCollections.UserListinPythonCollections.UserStringinPythonPythonAdvanceOSModuleinPythonwithExamplesFunctionalProgramminginPythonMetaprogrammingwithMetaclassesinPythonAbstractClassesinPythonMultithreadinginPython|Set1MultithreadinginPython|Set2(Synchronization)MultiprocessinginPython|Set1(Introduction)MultiprocessinginPython|Set2(Communicationbetweenprocesses)SocketProgramminginPythonSocketProgrammingwithMulti-threadinginPythonPythonNumPyNumPyTutorialPythonNumpyNumpy|ndarrayNumpy|ArrayCreationNumpy|IndexingBasicSlicingandAdvancedIndexinginNumPyPythonNumpy|DataTypeObjectsNumpy|IteratingOverArrayNumpy|BinaryOperationsNumpy|MathematicalFunctionNumpy|StringOperationsNumpy|LinearAlgebraNumpy|Sorting,SearchingandCountingRandomsamplinginnumpy|randint()functionRandomsamplinginnumpy|random_sample()functionRandomsamplinginnumpy|ranf()functionRandomsamplinginnumpy|random_integers()functionNumpyufunc|UniversalfunctionsPythonPandasPandasTutorialIntroductiontoPandasinPythonHowtoInstallPythonPandasonWindowsandLinux?Python|PandasDataFrameCreatingaPandasDataFramePython|PandasSeriesCreatingaPandasSeriesPython|PandasDataframe/Series.head()methodPython|PandasDataframe.describe()methodDealingwithRowsandColumnsinPandasDataFramePython|PandasExtractingrowsusing.loc[]Python|ExtractingrowsusingPandas.iloc[]IndexingandSelectingDatawithPandasBooleanIndexinginPandasPandasGroupByPython|PandasMerging,Joining,andConcatenatingPython|WorkingwithdateandtimeusingPandasPython|PandasWorkingWithTextDataPython|Readcsvusingpandas.read_csv()Python|WorkingwithPandasandXlsxWriter|Set–1PythonDjangoDjangoTutorialDjangoBasicsDjangoIntroductionandInstallationDjangoProjectMVTStructureHowtoCreateaBasicProjectusingMVTinDjango?HowtoCreateanAppinDjango?DjangoFormsRenderHTMLForms(GET&POST)inDjangoDjangoformfieldcustomwidgetsDjangoModelForm–CreateformfromModelsDjangoFormsetsDjangoModelFormSetsDjangoTemplatesViewsInDjango|PythonDjangoCRUD(Create,Retrieve,Update,Delete)FunctionBasedViewsClassBasedGenericViewsDjango(Create,Retrieve,Update,Delete)DjangoModelsDjangoORM–Inserting,Updating&DeletingDataDjangoBasicAppModel–MakemigrationsandMigratePythonJSONPythonJSONWorkingWithJSONDatainPythonRead,WriteandParseJSONusingPythonAppendtoJSONfileusingPythonSerializingJSONdatainPythonDeserializeJSONtoObjectinPythonPythonCSVWorkingwithcsvfilesinPythonReadingCSVfilesinPythonWritingCSVfilesinPythonPythonMySQLPythonMySQLConnectMySQLdatabaseusingMySQL-ConnectorPythonPythonMySQL–CreateDatabasePython:MySQLCreateTablePythonMySQL–InsertintoTablePythonMySQL–SelectQueryPythonMySQL–WhereClausePythonMySQL–OrderByClausePythonMySQL–DeleteQueryPythonMySQL–DropTablePythonMySQL–UpdateQueryPythonMySQL–LimitClausePythonMySQL–JoinPythonMongoDBPythonMongoDBTutorialInstallingMongoDBonWindowswithPythonMongoDBandPythonCreateadatabaseinMongoDBusingPythonPythonMongoDB–insert_oneQueryPythonMongoDB–insert_manyQueryPythonMongoDB–FindPythonMongoDB–QueryPythonMongoDB–SortMongoDBpython|DeleteDataandDropCollectionPythonMongodb–Delete_one()PythonMongodb–Delete_many()PythonMongoDB–Update_one()PythonMongoDB–Update_manyQueryPythonMongoDB–LimitQueryPythonMongoDB–create_indexQueryPythonMongoDB–drop_indexQueryPythonOpenCVOpenCVPythonTutorialIntroductiontoOpenCVHowtoInstallOpenCVforPythononWindows?ReadinganimageinOpenCVusingPythonOpenCV|SavinganImageArithmeticOperationsonImagesusingOpenCV|Set-1(AdditionandSubtraction)ArithmeticOperationsonImagesusingOpenCV|Set-2(BitwiseOperationsonBinaryImages)ImageResizingusingOpenCV|PythonImageProcessinginPython(Scaling,Rotating,ShiftingandEdgeDetection)Python|ImageblurringusingOpenCVErosionandDilationofimagesusingOpenCVinpythonPython|ThresholdingtechniquesusingOpenCV|Set-1(SimpleThresholding)Python|ThresholdingtechniquesusingOpenCV|Set-2(AdaptiveThresholding)Python|ThresholdingtechniquesusingOpenCV|Set-3(OtsuThresholding)FilterColorwithOpenCVPython|BilateralFilteringPython|BackgroundsubtractionusingOpenCVPython|PlayavideousingOpenCVExtractimagesfromvideoinPythonFaceDetectionusingPythonandOpenCVwithwebcamPythonSeleniumSeleniumPythonTutorialSeleniumBasics–Components,Features,UsesandLimitationsComponentsofSeleniumSeleniumPythonIntroductionandInstallationNavigatinglinksusinggetmethod–SeleniumPythonInteractingwithWebpage–SeleniumPythonLocatingsingleelementsinSeleniumPythonLocatingmultipleelementsinSeleniumPythonLocatorStrategies–SeleniumPythonActionChainsinSeleniumPythonExceptions–SeleniumPythonPythonTkinterPythonTkinterTutorialIntroductiontoTkinterWhatareWidgetsinTkinter?Python|CreatingabuttonintkinterPythonTkinter–LabelRadioButtoninTkinter|PythonPythonTkinter–CheckbuttonWidgetPythonTkinter–CanvasWidgetComboboxWidgetintkinter|PythonPythonTkinter–EntryWidgetPythonTkinter–TextWidgetPythonTkinter–MessagePython|MenuwidgetinTkinterPythonTkinter–SpinBoxProgressbarwidgetinTkinter|PythonPython-TkinterScrollbarPythonTkinter–ScrolledTextWidgetPythonTkinter–ListBoxWidgetPythonTkinter–FrameWidgetPythonTkinter–ScaleWidgetHierarchicaltreeviewinPythonGUIapplicationPython-TkinterTreeviewscrollbarPythonTkinter–ToplevelWidgetPython|askopenfile()functioninTkinterPython|asksaveasfile()functioninTkinterPython–TkinteraskquestionDialogPythonTkinter–MessageBoxWidgetPython|place()methodinTkinterPython|grid()methodinTkinterPython|pack()methodinTkinterPython|PanedWindowWidgetinTkinterPython|BindingfunctioninTkinterPythonTkinter–ValidatingEntryWidgetPythonKivyKivyTutorialIntroductiontoKivy;ACross-platformPythonFrameworkPython|AddLabeltoakivywindowPython|TextinputwidgetinkivyPython|CanvasinkivyPython|CheckboxwidgetinKivyPython|DropdownlistinkivyPython|CarouselWidgetInKivyPython|BoxLayoutwidgetinKivyPython|SliderwidgetinKivyPython|PopupwidgetinKivyPython|SwitchwidgetinKivyPython|SpinnerwidgetinkivyPython|ProgressBarwidgetinkivyPython|WorkingwithbuttonsinKivyPython|FloatLayoutinKivyGridLayoutsinKivy|PythonPython|StackLayoutinKivyPython|AnchorLayoutinKivyPython|RelativeLayoutinKivyPython|PageLayoutinKivyDataVisualizationMatplotlibTutorialPythonSeabornTutorialPythonPlotlytutorialPythonBokehtutorial–InteractiveDataVisualizationwithBokehTableauTutorialPythonExamplesandQuizPythonProgrammingExamplesPythonExercises,PracticeQuestionsandSolutionsPythonMultipleChoiceQuestionsPython|Readcsvusingpandas.read_csv()ViewDiscussion ImproveArticle SaveArticle LikeArticle DifficultyLevel: EasyLastUpdated: 30Sep,2022ReadDiscussViewDiscussion ImproveArticle SaveArticle LikeArticle ToaccessdatafromtheCSVfile,werequireafunctionread_csv()thatretrievesdataintheformoftheDataframe.Syntaxofread_csv() Syntax:pd.read_csv(filepath_or_buffer,sep=’,’,header=’infer’, index_col=None,usecols=None,engine=None,skiprows=None,nrows=None) Parameters: filepath_or_buffer:Itisthelocationofthefilewhichistoberetrievedusingthisfunction.ItacceptsanystringpathorURLofthefile.sep:Itstandsforseparator,defaultis‘,‘asinCSV(commaseparatedvalues).header:Itacceptsint,alistofint,rownumberstouseasthecolumnnames,andthestartofthedata.Ifnonamesarepassed,i.e.,header=None,then, itwilldisplaythefirstcolumnas0,thesecondas1,andsoon.usecols:ItisusedtoretrieveonlyselectedcolumnsfromtheCSVfile.nrows:Itmeansanumberofrowstobedisplayedfromthedataset.index_col:IfNone,therearenoindexnumbersdisplayedalongwithrecords. skiprows:Skipspassedrowsinthenewdataframe.ReadCSVusingPandasread_csvBeforeusingthisfunction,wemustimportthePandaslibrary,wewillloadtheCSVfile.PYTHON3#Importpandasimportpandasaspd #readingcsvfilepd.read_csv("example1.csv")Output: Example1:Usingsepinread_csv()Inthisexample,wewillmanipulateourexistingCSVfileandthenaddsomespecialcharacterstoseehowthesepparameterworks.Python3#headbrain1="totalbill_tip,sex:smoker,day_time,size#16.99,1.01:Female|No,Sun,Dinner,2#10.34,1.66,Male,No|Sun:Dinner,3#21.01:3.5_Male,No:Sun,Dinner,3#23.68,3.31,Male|No,Sun_Dinner,2#24.59:3.61,Female_No,Sun,Dinner,4#25.29,4.71|Male,No:Sun,Dinner,4" #Importingpandaslibraryimportpandasaspd #Loadthedataofcsvdf=pd.read_csv('headbrain1.csv', sep='[:,|_]', engine='python') #PrinttheDataframedfOutput: Example2:Usingusecolsinread_csv()Here,wearespecifyingonly3columns,i.e.[“tip”,“sex”,“time”]toloadandweusetheheader0asitsdefaultheader.Python3df=pd.read_csv('example1.csv', header=0, usecols=["tip","sex","time"]) dfOutput: Example3:Usingindex_colinread_csv()Here,weusethe“sex”indexfirstandthenthe“tip”index,wecansimplyreindextheheaderwithindex_colparameter.Python3df=pd.read_csv('example1.csv', header=0, index_col=["sex","tip"], usecols=["tip","sex","time"]) dfOutput: Example4:Usingnrowsinread_csv()Here,wejustdisplayonly5rowsusingnrowsparameter.Python3df=pd.read_csv('example1.csv', header=0, index_col=["tip","sex"], usecols=["tip","sex","time"], nrows=5) dfOutput: Example5:Usingskiprowsinread_csv()TheskiprowshelptoskipsomerowsinCSV,i.e,hereyouwillobservethattheupperrowandthelastrowfromtheoriginalCSVdatahavebeenskipped.Python3pd.read_csv("example1.csv",skiprows=[1,12])Output: MyPersonalNotes arrow_drop_upSave LikeNext Python|WorkingwithPandasandXlsxWriter|Set-1RecommendedArticlesPage:22,Jan2006,May2123,Jan1923,Feb2123,Feb2103,Mar2106,Apr2225,Mar2106,Jul2003,Mar2116,Apr2109,Sep2116,Dec2130,Jun2129,Jun2030,Apr2029,Jun2029,Aug2030,Aug2010,Dec2017,Dec2013,Jan2101,Feb2123,Feb21ArticleContributedBy:Kartikaybhutani@KartikaybhutaniVotefordifficultyCurrentdifficulty: EasyEasy Normal Medium Hard ExpertImprovedBy:anikakapoorsooda367sagartomar9927sheetal18junesurajkumarguptainternArticleTags:python-modulesPythonPracticeTags:pythonReportIssueWritingcodeincomment? Pleaseuseide.geeksforgeeks.org, generatelinkandsharethelinkhere. LoadCommentsPleaseLogintocomment...What'sNewViewDetailsViewDetailsViewDetailsImproveyourCodingSkillswithPracticeTryIt! Weusecookiestoensureyouhavethebestbrowsingexperienceonourwebsite.Byusingoursite,you acknowledgethatyouhavereadandunderstoodour CookiePolicy& PrivacyPolicy GotIt! StartYourCodingJourneyNow!Login Register
延伸文章資訊
- 1How to Import a CSV into a Jupyter Notebook with Python and Pandas
- 2[Day07]Pandas操作資料的函數! - iT 邦幫忙
使用Python進行資料分析系列第7 篇 ... 第七天了,上一篇提介紹了python內的一個套件pandas內兩個重要的資料結構, ... 使用 read_csv() 讀取一個CSV的檔案
- 3How to read CSV File into Python using Pandas | by Barney H.
Pandas read_csv() function imports a CSV file to DataFrame format. Here are some options: filepat...
- 4pandas.read_csv — pandas 1.5.0 documentation
Read a comma-separated values (csv) file into DataFrame. Also supports optionally iterating or br...
- 5Import CSV file as a Pandas DataFrame - Stack Overflow
To read a CSV file as a pandas DataFrame, you'll need to use pd.read_csv . But this isn't where t...